Skip to content

Commit

Permalink
build: make docker compose work
Browse files Browse the repository at this point in the history
  • Loading branch information
jarvis8x7b committed Aug 8, 2024
1 parent 1f292f2 commit e6b27b5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .env.standalone.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
REDIS_USERNAME=
REDIS_PASSWORD=

DB_HOST=
DB_HOST=postgres-service:5432
DB_NAME=
DB_USERNAME=
DB_PASSWORD=
Expand Down
61 changes: 36 additions & 25 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ volumes:

services:
redis:
env_file:
- .env
image: redis/redis-stack-server:7.4.0-v0
environment:
# CHANGE THE PASSWORD TO A PASSWORD YOU WANT TO USE
REDIS_ARGS: "--requirepass ${REDIS_PASSWORD} --user ${REDIS_USERNAME} on >${REDIS_PASSWORD} ~* allcommands"

healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
Expand All @@ -21,17 +22,21 @@ services:
volumes:
- redis-volume:/data

postgres:
postgres-service:
env_file:
- .env
image: postgres:15.7
environment:
POSTGRES_DB: ${DB_NAME}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_PASSWORD: ${DB_PASSWORD}
healthcheck:
test: usr/bin/pg_isready
test: ["CMD-SHELL", "pg_isready -U ${DB_USERNAME}"]
interval: 5s
timeout: 5s
retries: 5
ports:
- "5432:5432"
expose:
- 5432
volumes:
Expand Down Expand Up @@ -106,46 +111,52 @@ services:
condition: service_healthy

worker-api:
env_file:
- .env
platform: linux/amd64
build:
context: .
dockerfile: Dockerfile
env_file:
- .env
environment:
RUNTIME_ENV: local
SERVER_PORT: 8081
SUBNET_UID: 98
VALIDATOR_MIN_STAKE: 20000
CORS_ALLOWED_ORIGINS: http://localhost*
SUBSTRATE_API_URL: sidecar:8080
ETHEREUM_NODE: ${ETHEREUM_NODE}
# authentication
TOKEN_EXPIRY: 24
JWT_SECRET: ${JWT_SECRET}
# postgres
DB_NAME: ${DB_NAME}
DB_HOST: ${DB_HOST}
DB_USERNAME: ${DB_USERNAME}
DB_PASSWORD: ${DB_PASSWORD}
DATABASE_URL: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
# aws s3 setup
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
S3_PUBLIC_URL: ${S3_PUBLIC_URL}
# redis
REDIS_USERNAME: ${REDIS_USERNAME}
REDIS_PASSWORD: ${REDIS_PASSWORD}
REDIS_HOST: localhost
REDIS_PORT: 6379

# these envs get sourced from .env so we dont need to rebuild
# # postgres
# ETHEREUM_NODE: ${ETHEREUM_NODE}
# JWT_SECRET: ${JWT_SECRET}
# DB_NAME: ${DB_NAME}
# DB_HOST: ${DB_HOST}
# DB_USERNAME: ${DB_USERNAME}
# DB_PASSWORD: ${DB_PASSWORD}
# DATABASE_URL: postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_HOST}/${DB_NAME}
# # aws s3 setup
# AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY_ID}
# AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
# AWS_S3_BUCKET_NAME: ${AWS_S3_BUCKET_NAME}
# S3_PUBLIC_URL: ${S3_PUBLIC_URL}
# # redis
# REDIS_USERNAME: ${REDIS_USERNAME}
# REDIS_PASSWORD: ${REDIS_PASSWORD}
ports:
- "8081:8080"
- "8080:8081"
depends_on:
redis:
condition: service_healthy
postgres:
postgres-service:
condition: service_healthy
sidecar:
condition: service_healthy
command: ["./service"]
command: ["./service", "--debug"]
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8081"]
interval: 10s
timeout: 10s
retries: 5

0 comments on commit e6b27b5

Please sign in to comment.