Repository navigation
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
122 lines (110 loc) · 3.3 KB
/
Copy pathdocker-compose.yml
File metadata and controls
122 lines (110 loc) · 3.3 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
x-healthcheck-props: &healthcheck-props
interval: 5s
timeout: 20s
retries: 10
services:
mongo:
image: mongo:8
restart: always
ports:
- "27017:27017"
volumes:
- "mongo-data:/data/db"
command: --storageEngine=wiredTiger
healthcheck:
<<: *healthcheck-props
test: [ "CMD-SHELL", "echo 'db.runCommand(\"ping\").ok' | mongosh 127.0.0.1:27017/productiondb --quiet | grep -q 1" ]
redis:
image: redis:8-alpine
restart: always
ports:
- "6379:6379"
volumes:
- "redis-data:/data"
healthcheck:
<<: *healthcheck-props
test: [ "CMD-SHELL", "redis-cli PING" ]
storage:
image: rustfs/rustfs:latest
restart: always
ports:
- "9000:9000"
- "9001:9001"
environment:
RUSTFS_ACCESS_KEY: ${S3_ACCESS_KEY}
RUSTFS_SECRET_KEY: ${S3_SECRET_KEY}
volumes:
- "storage-data:/data"
healthcheck:
<<: *healthcheck-props
test: [ "CMD-SHELL", "curl -f http://127.0.0.1:9000/health" ]
# Uses the AWS CLI (speaks plain S3 against RustFS) rather than MinIO's own
# `mc` client — minio/mc was pulled from both Docker Hub and quay.io in
# late 2025 when MinIO went source-only, so an `mc`-based image can no
# longer be pulled at all.
create-bucket:
image: amazon/aws-cli:2.36.49
restart: "no"
depends_on:
storage:
condition: service_healthy
environment:
AWS_ACCESS_KEY_ID: ${S3_ACCESS_KEY}
AWS_SECRET_ACCESS_KEY: ${S3_SECRET_KEY}
AWS_DEFAULT_REGION: ${S3_REGION}
S3_BUCKET: ${S3_BUCKET}
configs:
- source: cors.json
target: /tmp/cors.json
- source: bucket-policy.json
target: /tmp/bucket-policy.json
entrypoint:
- /bin/bash
- -c
- |
set -e
until aws --endpoint-url http://storage:9000 s3api list-buckets >/dev/null 2>&1; do
echo 'storage is not ready yet, retrying in 2 seconds...'
sleep 2
done
echo 'create bucket if not exists'
aws --endpoint-url http://storage:9000 s3api head-bucket --bucket "$$S3_BUCKET" 2>/dev/null \
|| aws --endpoint-url http://storage:9000 s3api create-bucket --bucket "$$S3_BUCKET"
echo 'set policy PUBLIC (download only) for bucket'
aws --endpoint-url http://storage:9000 s3api put-bucket-policy --bucket "$$S3_BUCKET" --policy file:///tmp/bucket-policy.json
echo 'set cors rules'
aws --endpoint-url http://storage:9000 s3api put-bucket-cors --bucket "$$S3_BUCKET" --cors-configuration file:///tmp/cors.json
configs:
cors.json:
content: |
{
"CORSRules": [
{
"AllowedOrigins": [
"http://localhost:3000",
"https://daniel.heene.io",
"https://daniel.heene.dev",
"https://daniel.heene.nexus"
],
"AllowedMethods": [ "GET", "PUT", "POST", "HEAD" ],
"AllowedHeaders": [ "*" ]
}
]
}
bucket-policy.json:
content: |
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": [ "s3:GetObject" ],
"Resource": [ "arn:aws:s3:::${S3_BUCKET}/*" ]
}
]
}
volumes:
mongo-data:
redis-data:
storage-data: