Update docker-compose.yml
Use `extends` rule with a template to enable both dev and prod envs on the same machine
This commit is contained in:
parent
a82840e0bf
commit
37327ed331
|
@ -0,0 +1,27 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
usermanager-api-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: usermanager-api
|
||||
container_name: fids_usermanager_api_dev
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db-dev/${POSTGRES_DB}
|
||||
depends_on:
|
||||
usermanager-db-dev:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- auth-dev
|
||||
|
||||
usermanager-db-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: usermanager-db
|
||||
container_name: fids_usermanager_db_dev
|
||||
networks:
|
||||
- auth-dev
|
||||
|
||||
networks:
|
||||
auth-dev:
|
||||
driver: bridge
|
|
@ -2,19 +2,9 @@ version: '3.8'
|
|||
|
||||
services:
|
||||
usermanager-api:
|
||||
container_name: fids_usermanager_api
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: usermanager-api
|
||||
depends_on:
|
||||
usermanager-db:
|
||||
condition: service_healthy
|
||||
|
@ -22,24 +12,17 @@ services:
|
|||
- auth
|
||||
|
||||
usermanager-db:
|
||||
container_name: fids_usermanager_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: usermanager-db
|
||||
volumes:
|
||||
- flights_db:/var/lib/postgresql/data
|
||||
networks:
|
||||
- auth
|
||||
|
||||
networks:
|
||||
auth:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
flights_db:
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
usermanager-api:
|
||||
container_name: fids_usermanager_api
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@usermanager-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
|
||||
usermanager-db:
|
||||
container_name: fids_usermanager_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
|
@ -16,7 +16,7 @@ class DevelopmentConfig(BaseConfig):
|
|||
|
||||
class TestingConfig(BaseConfig):
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_TEST_URL")
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
BCRYPT_LOG_ROUNDS = 4
|
||||
ACCESS_TOKEN_EXPIRATION = 5
|
||||
REFRESH_TOKEN_EXPIRATION = 5
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
flights-api-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: flights-api
|
||||
container_name: fids_flights_api_dev
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db-dev/${POSTGRES_DB}
|
||||
depends_on:
|
||||
flights-api-db-dev:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- flights-dev
|
||||
- subscriptions-dev
|
||||
|
||||
flights-api-db-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: flights-api-db
|
||||
container_name: fids_flights_db_dev
|
||||
networks:
|
||||
- flights-dev
|
||||
|
||||
networks:
|
||||
subscriptions-dev:
|
||||
name: subscription-domain_subscriptions-dev
|
||||
external: true
|
||||
flights-dev:
|
||||
driver: bridge
|
|
@ -1,21 +1,10 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
||||
flights-api:
|
||||
container_name: fids_flights_api
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: flights-api
|
||||
depends_on:
|
||||
flights-api-db:
|
||||
condition: service_healthy
|
||||
|
@ -24,21 +13,11 @@ services:
|
|||
- subscriptions
|
||||
|
||||
flights-api-db:
|
||||
container_name: fids_flights_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: flights-api-db
|
||||
volumes:
|
||||
- flights_db:/var/lib/postgresql/data
|
||||
networks:
|
||||
- flights
|
||||
|
||||
|
@ -48,3 +27,6 @@ networks:
|
|||
external: true
|
||||
flights:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
flights_db:
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
flights-api:
|
||||
container_name: fids_flights_api
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@flights-api-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
|
||||
flights-api-db:
|
||||
container_name: fids_flights_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
|
@ -4,31 +4,21 @@ import os
|
|||
class BaseConfig:
|
||||
TESTING = False
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SECRET_KEY = "my_precious"
|
||||
ACCESS_TOKEN_EXPIRATION = 900 # 15 minutes
|
||||
REFRESH_TOKEN_EXPIRATION = 2592000 # 30 days
|
||||
|
||||
|
||||
class DevelopmentConfig(BaseConfig):
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
BCRYPT_LOG_ROUNDS = 4
|
||||
|
||||
|
||||
class TestingConfig(BaseConfig):
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_TEST_URL")
|
||||
BCRYPT_LOG_ROUNDS = 4
|
||||
ACCESS_TOKEN_EXPIRATION = 5
|
||||
REFRESH_TOKEN_EXPIRATION = 5
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
|
||||
|
||||
class ProductionConfig(BaseConfig):
|
||||
BCRYPT_LOG_ROUNDS = 13
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "my_precious")
|
||||
|
||||
def __init__(self):
|
||||
self.SECRET_KEY = os.getenv("SECRET_KEY", "my_precious")
|
||||
url = os.environ.get("DATABASE_URL")
|
||||
if url is not None and url.startswith("postgres://"):
|
||||
url = url.replace("postgres://", "postgresql://", 1)
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
api-gateway-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: api-gateway
|
||||
container_name: fids_api_gateway_dev
|
||||
ports:
|
||||
- 5001:5002
|
||||
networks:
|
||||
- auth-dev
|
||||
- flights-dev
|
||||
- gateway-dev
|
||||
- subscriptions-dev
|
||||
|
||||
networks:
|
||||
auth-dev:
|
||||
name: auth-domain_auth-dev
|
||||
external: true
|
||||
flights-dev:
|
||||
name: flights-domain_flights-dev
|
||||
external: true
|
||||
subscriptions-dev:
|
||||
name: subscription-domain_subscriptions-dev
|
||||
external: true
|
||||
gateway-dev:
|
||||
driver: bridge
|
|
@ -1,22 +1,12 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
||||
api-gateway:
|
||||
container_name: fids_api_gateway
|
||||
image: ${API_IMAGE}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: api-gateway
|
||||
ports:
|
||||
- 5000:5002
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5002"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
networks:
|
||||
- auth
|
||||
- flights
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
api-gateway:
|
||||
container_name: fids_api_gateway
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5002"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
|
@ -0,0 +1,27 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
subscriptions-api-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: subscriptions-api
|
||||
container_name: fids_subscriptions_api_dev
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@subscriptions-db-dev/${POSTGRES_DB}
|
||||
depends_on:
|
||||
subscriptions-db-dev:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- subscriptions-dev
|
||||
|
||||
subscriptions-db-dev:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: subscriptions-db
|
||||
container_name: fids_subscriptions_db_dev
|
||||
networks:
|
||||
- subscriptions-dev
|
||||
|
||||
networks:
|
||||
subscriptions-dev:
|
||||
driver: bridge
|
|
@ -1,49 +1,28 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
|
||||
subscriptions-api:
|
||||
container_name: fids_subscriptions_api
|
||||
image: ${API_IMAGE}
|
||||
ports:
|
||||
- 5002:5000
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@subscriptions-api-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
- TOKEN=${TOKEN}
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: subscriptions-api
|
||||
depends_on:
|
||||
subscriptions-api-db:
|
||||
subscriptions-db:
|
||||
condition: service_healthy
|
||||
networks:
|
||||
- subscriptions
|
||||
|
||||
subscriptions-api-db:
|
||||
container_name: fids_subscriptions_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
||||
subscriptions-db:
|
||||
extends:
|
||||
file: docker-template.yml
|
||||
service: subscriptions-db
|
||||
volumes:
|
||||
- subscriptions_db:/var/lib/postgresql/data
|
||||
networks:
|
||||
- subscriptions
|
||||
|
||||
networks:
|
||||
subscriptions:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
subscriptions_db:
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
version: '3.8'
|
||||
|
||||
services:
|
||||
subscriptions-api:
|
||||
container_name: fids_subscriptions_api
|
||||
image: ${API_IMAGE}
|
||||
healthcheck:
|
||||
test: ["CMD", "nc", "-vz", "-w1", "localhost", "5000"]
|
||||
interval: 2s
|
||||
timeout: 2s
|
||||
retries: 5
|
||||
start_period: 2s
|
||||
environment:
|
||||
- TEST_TARGET=${TEST_TARGET}
|
||||
- PORT=5000
|
||||
- DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASS}@subscriptions-db/${POSTGRES_DB}
|
||||
- APP_SETTINGS=${APP_SETTINGS}
|
||||
- TOKEN=${TOKEN}
|
||||
|
||||
subscriptions-db:
|
||||
container_name: fids_subscriptions_db
|
||||
build:
|
||||
context: ./db
|
||||
dockerfile: Dockerfile
|
||||
healthcheck:
|
||||
test: psql postgres --command "select 1" -U ${POSTGRES_USER}
|
||||
interval: 2s
|
||||
timeout: 10s
|
||||
retries: 10
|
||||
start_period: 2s
|
||||
expose:
|
||||
- 5432
|
||||
environment:
|
||||
- POSTGRES_USER=${POSTGRES_USER}
|
||||
- POSTGRES_PASSWORD=${POSTGRES_PASS}
|
|
@ -4,31 +4,21 @@ import os
|
|||
class BaseConfig:
|
||||
TESTING = False
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SECRET_KEY = "my_precious"
|
||||
ACCESS_TOKEN_EXPIRATION = 900 # 15 minutes
|
||||
REFRESH_TOKEN_EXPIRATION = 2592000 # 30 days
|
||||
|
||||
|
||||
class DevelopmentConfig(BaseConfig):
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
BCRYPT_LOG_ROUNDS = 4
|
||||
|
||||
|
||||
class TestingConfig(BaseConfig):
|
||||
TESTING = True
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_TEST_URL")
|
||||
BCRYPT_LOG_ROUNDS = 4
|
||||
ACCESS_TOKEN_EXPIRATION = 5
|
||||
REFRESH_TOKEN_EXPIRATION = 5
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
|
||||
|
||||
class ProductionConfig(BaseConfig):
|
||||
BCRYPT_LOG_ROUNDS = 13
|
||||
SQLALCHEMY_DATABASE_URI = os.environ.get("DATABASE_URL")
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "my_precious")
|
||||
|
||||
def __init__(self):
|
||||
self.SECRET_KEY = os.getenv("SECRET_KEY", "my_precious")
|
||||
url = os.environ.get("DATABASE_URL")
|
||||
if url is not None and url.startswith("postgres://"):
|
||||
url = url.replace("postgres://", "postgresql://", 1)
|
||||
|
|
Loading…
Reference in New Issue