Created
June 1, 2023 23:36
-
-
Save tciuro/86f9e1748ee4c163942f10ac23a340da to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Docker Compose file for Vapor | |
# | |
# Install Docker on your system to run and test | |
# your Vapor app in a production-like environment. | |
# | |
# Note: This file is intended for testing and does not | |
# implement best practices for a production deployment. | |
# | |
# Learn more: https://docs.docker.com/compose/reference/ | |
# | |
# Build images: docker-compose build | |
# Start app: docker-compose up app | |
# Start database: docker-compose up db | |
# Run migrations: docker-compose run migrate | |
# Stop all: docker-compose down (add -v to wipe db) | |
# | |
version: '3.7' | |
volumes: | |
myapp_data: | |
myapp_test_data: | |
x-db_environment: &db_environment | |
PGDATA: /var/lib/postgresql/data/pgdata | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: vapor_password | |
POSTGRES_DB: myapp_database | |
x-db_test_environment: &db_test_environment | |
PGDATA: /var/lib/postgresql/data/pgdata | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: vapor_password | |
POSTGRES_DB: myapp_database_test | |
x-shared_environment: &shared_environment | |
DATABASE_USER: postgres | |
DATABASE_PASSWORD: vapor_password | |
DATABASE_NAME: myapp_database | |
DATABASE_HOST: myapp_database | |
DATABASE_PORT: 5432 | |
LOG_LEVEL: ${LOG_LEVEL:-debug} | |
services: | |
app: | |
image: myapp-server:latest | |
build: | |
context: . | |
environment: | |
<<: *shared_environment | |
env_file: .env.production | |
depends_on: | |
myapp_database: | |
condition: service_healthy | |
myapp_database_test: | |
condition: service_healthy | |
restart: always | |
ports: | |
- '8443:8443' | |
# user: '0' # uncomment to run as root for testing purposes even though Dockerfile defines 'vapor' user. | |
command: | |
[ | |
"serve", | |
"--env", | |
"production", | |
"--hostname", | |
"0.0.0.0", | |
"--port", | |
"8443" | |
] | |
migrate: | |
image: myapp-server:latest | |
build: | |
context: . | |
environment: | |
<<: *shared_environment | |
depends_on: | |
- myapp_database | |
command: ["migrate", "--yes"] | |
deploy: | |
replicas: 0 | |
revert: | |
image: myapp-server:latest | |
build: | |
context: . | |
environment: | |
<<: *shared_environment | |
depends_on: | |
- myapp_database | |
command: ["migrate", "--revert", "--yes"] | |
deploy: | |
replicas: 0 | |
myapp_database: | |
image: postgres:14-alpine | |
volumes: | |
- myapp_data:/var/lib/postgresql/data/pgdata | |
environment: | |
<<: *db_environment | |
healthcheck: | |
test: ["CMD-SHELL", "pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
ports: | |
- '5432:5432' | |
myapp_database_test: | |
image: postgres:14-alpine | |
volumes: | |
- myapp_test_data:/var/lib/postgresql/data/pgdata_test | |
environment: | |
<<: *db_test_environment | |
healthcheck: | |
test: ["CMD-SHELL", "pg_isready -U postgres"] | |
interval: 10s | |
timeout: 5s | |
retries: 5 | |
ports: | |
- '5433:5432' | |
ngrok: | |
image: ngrok/ngrok:latest | |
restart: unless-stopped | |
command: | |
- "start" | |
- "--all" | |
- "--config" | |
- "/etc/ngrok.yml" | |
volumes: | |
- ./ngrok.yml:/etc/ngrok.yml | |
ports: | |
- 4040:4040 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment