Skip to content

Commit cfe608a

Browse files
chore: add localstack S3 to docker compose (#145)
1 parent d9671bf commit cfe608a

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,6 @@ next-env.d.ts
3939
dist/
4040

4141
diagram.txt
42+
43+
# localstack
44+
localstack/data/

compose.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ services:
99
DATABASE_URL: postgresql://postgres:asdfasdf@db:5432/postgres
1010
TEST_DATABASE_URL: postgresql://postgres:asdfasdf@test_db:5432/postgres
1111
JOB_FUNCTION_URL: http://job_worker:8080/2015-03-31/functions/function/invocations
12+
AWS_REGION: us-east-1
13+
AWS_ACCESS_KEY_ID: test
14+
AWS_SECRET_ACCESS_KEY: test
15+
AWS_ENDPOINT_URL_S3: http://localstack:4566
16+
AWS_S3_FORCE_PATH_STYLE: "true"
1217
volumes:
1318
- ./:/app
1419
- server-node-modules:/app/node_modules
@@ -17,6 +22,8 @@ services:
1722
depends_on:
1823
db:
1924
condition: service_healthy
25+
localstack:
26+
condition: service_healthy
2027
job_worker:
2128
build:
2229
context: .
@@ -25,6 +32,12 @@ services:
2532
restart: always
2633
environment:
2734
DATABASE_URL: postgresql://postgres:asdfasdf@db:5432/postgres
35+
AWS_REGION: us-east-1
36+
AWS_ACCESS_KEY_ID: test
37+
AWS_SECRET_ACCESS_KEY: test
38+
AWS_ENDPOINT_URL_S3: http://localstack:4566
39+
AWS_S3_FORCE_PATH_STYLE: "true"
40+
EXPORT_PUBLIC_S3_ENDPOINT: http://localhost:4566
2841
volumes:
2942
- ./:/app
3043
- job-worker-node-modules:/app/node_modules
@@ -33,9 +46,27 @@ services:
3346
depends_on:
3447
db:
3548
condition: service_healthy
49+
localstack:
50+
condition: service_healthy
3651
env_file:
3752
- path: .env
3853
required: false
54+
localstack:
55+
image: localstack/localstack:4
56+
environment:
57+
- SERVICES=s3
58+
- DEFAULT_REGION=us-east-1
59+
- LS_LOG=warn
60+
volumes:
61+
- ./localstack/data:/var/lib/localstack
62+
- ./localstack/init:/etc/localstack/init
63+
ports:
64+
- 4566:4566
65+
healthcheck:
66+
test: ["CMD", "bash", "-c", "awslocal s3 ls >/dev/null 2>&1"]
67+
interval: 10s
68+
timeout: 5s
69+
retries: 5
3970
db:
4071
build:
4172
dockerfile: db/Dockerfile

localstack/init/ready.d/init.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/sh
2+
set -eu
3+
4+
bucket_prefix="${EXPORT_BUCKET_PREFIX:-gbt-exports}"
5+
bucket_name="${bucket_prefix}-local"
6+
7+
if ! awslocal s3api head-bucket --bucket "$bucket_name" >/dev/null 2>&1; then
8+
awslocal s3 mb "s3://${bucket_name}" >/dev/null
9+
fi
10+
11+
echo "Localstack S3 bucket ready: ${bucket_name}"

0 commit comments

Comments
 (0)