forked from hotosm/ScaleODM
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompose.yaml
More file actions
149 lines (140 loc) · 4.28 KB
/
Copy pathcompose.yaml
File metadata and controls
149 lines (140 loc) · 4.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# This file is used for running tests with an attached database
#
# Prerequisites:
# 1. Talos cluster must be running (created via: just test cluster-init)
# 2. Kubeconfig must be configured and point to the Talos cluster
#
# Quick start:
# just dev # Setup Talos cluster and start all services
networks:
net:
name: scaleodm
volumes:
db_data:
rustfs_data:
services:
api:
image: "ghcr.io/hotosm/scaleodm:${TAG_OVERRIDE:-ci}"
build:
target: build
container_name: scaleodm
depends_on:
db:
condition: service_healthy
s3-init:
condition: service_completed_successfully
# Use host networking to access localhost Kubernetes API (Talos cluster)
# This also allows direct access to DB and S3 via localhost ports
network_mode: "host"
environment:
KUBECONFIG_PATH: /root/.kube/config
K8S_NAMESPACE: ${K8S_NAMESPACE:-argo}
SCALEODM_DATABASE_URL: ${SCALEODM_DATABASE_URL:-postgres://odm:odm@localhost:31101/scaleodm?sslmode=disable}
# Keep local compose S3 settings fixed for repeatable test runs.
AWS_S3_ENDPOINT: http://localhost:31102
AWS_ACCESS_KEY_ID: admin
AWS_SECRET_ACCESS_KEY: somelongpassword
SCALEODM_ARGO_ARCHIVE_LOG_BUCKET: argo-logs
volumes:
# Mount local files
- ./go.mod:/code/go.mod:ro
- ./go.sum:/code/go.sum:ro
- ./main.go:/code/main.go:ro
- ./main_test.go:/code/main_test.go:ro
- ./app:/code/app:ro
- ./testutil:/code/testutil:ro
- ./e2e:/code/e2e:ro
- $HOME/.kube/config:/root/.kube/config
entrypoint: go
command: run main.go
restart: "unless-stopped"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:31100/health"]
interval: 5s
retries: 10
start_period: 20s
timeout: 5s
db:
image: "docker.io/postgres:18-alpine"
container_name: scaleodm-db
environment:
- POSTGRES_USER=odm
- POSTGRES_PASSWORD=odm
- POSTGRES_DB=scaleodm
volumes:
- db_data:/var/lib/postgresql
ports:
- "31101:5432"
networks:
- net
restart: "unless-stopped"
healthcheck:
test: pg_isready -U odm -d scaleodm
start_period: 5s
interval: 10s
timeout: 5s
retries: 3
s3:
image: rustfs/rustfs:1.0.0-alpha.90
environment:
# Keep local test credentials fixed to avoid dotenv/.env drift.
RUSTFS_ACCESS_KEY: admin
RUSTFS_SECRET_KEY: somelongpassword
volumes:
- rustfs_data:/data
command: server /data --console-address ":9001"
ports:
- "31102:9000"
networks:
- net
restart: unless-stopped
healthcheck:
test: ["CMD", "sh", "-c", "curl -f http://localhost:9000/health"]
interval: 5s
timeout: 5s
retries: 20
start_period: 10s
s3-init:
image: docker.io/python:3.13-slim-trixie
depends_on:
s3:
condition: service_healthy
networks:
- net
environment:
AWS_ENDPOINT_URL: http://s3:9000
AWS_ACCESS_KEY_ID: admin
AWS_SECRET_ACCESS_KEY: somelongpassword
AWS_DEFAULT_REGION: us-east-1
restart: "on-failure:2"
entrypoint:
- /bin/sh
- -eu
- -c
- |
python -m pip install --no-cache-dir boto3 >/dev/null
python - <<'PY'
import os
import boto3
import botocore.config
import botocore.exceptions
s3 = boto3.client(
"s3",
endpoint_url=os.environ["AWS_ENDPOINT_URL"],
region_name=os.environ.get("AWS_DEFAULT_REGION", "us-east-1"),
aws_access_key_id=os.environ["AWS_ACCESS_KEY_ID"],
aws_secret_access_key=os.environ["AWS_SECRET_ACCESS_KEY"],
config=botocore.config.Config(s3={"addressing_style": "path"}),
)
for bucket in ("scaleodm-test", "argo-logs"):
try:
s3.create_bucket(Bucket=bucket)
print(f"Created bucket '{bucket}'")
except botocore.exceptions.ClientError as e:
code = e.response.get("Error", {}).get("Code", "")
if code in ("BucketAlreadyOwnedByYou", "BucketAlreadyExists"):
print(f"Bucket '{bucket}' already exists")
else:
raise
print("RustFS initialized.")
PY