Last active
February 7, 2025 11:46
-
-
Save SamuelChojnacki/097a7dd0d4724c24062d8fb1063dfeae to your computer and use it in GitHub Desktop.
Strapi v5 Docker compose with postgresql
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
## production : | |
services: | |
api: | |
container_name: api | |
platform: linux/amd64 | |
build: | |
context: . | |
dockerfile: ./Dockerfile.prod.yml | |
image: api:latest | |
restart: unless-stopped | |
env_file: | |
- .env | |
environment: | |
DATABASE_CLIENT: ${DATABASE_CLIENT} | |
DATABASE_HOST: ${DATABASE_HOST} | |
DATABASE_NAME: ${DATABASE_NAME} | |
DATABASE_USERNAME: ${DATABASE_USERNAME} | |
DATABASE_PORT: ${DATABASE_PORT} | |
JWT_SECRET: ${JWT_SECRET} | |
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET} | |
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | |
NODE_ENV: ${NODE_ENV} | |
DATABASE_SSL: ${DATABASE_SSL} | |
ports: | |
- "1337:1337" | |
networks: | |
- default | |
depends_on: | |
- db | |
db: | |
image: postgres:15-alpine | |
platform: linux/amd64 | |
container_name: postgres | |
restart: unless-stopped | |
environment: | |
POSTGRES_USER: ${DATABASE_USERNAME} | |
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} | |
POSTGRES_DB: ${DATABASE_NAME} | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
ports: | |
- "5432:5432" | |
networks: | |
- default | |
volumes: | |
postgres-data: | |
driver: local | |
## Developement | |
services: | |
api: | |
container_name: api | |
platform: linux/amd64 | |
build: | |
context: . | |
dockerfile: ./Dockerfile.dev.yml | |
image: api:latest | |
restart: unless-stopped | |
env_file: | |
- .env | |
environment: | |
DATABASE_CLIENT: ${DATABASE_CLIENT} | |
DATABASE_HOST: ${DATABASE_HOST} | |
DATABASE_NAME: ${DATABASE_NAME} | |
DATABASE_USERNAME: ${DATABASE_USERNAME} | |
DATABASE_PORT: ${DATABASE_PORT} | |
JWT_SECRET: ${JWT_SECRET} | |
ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET} | |
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | |
NODE_ENV: ${NODE_ENV} | |
DATABASE_SSL: ${DATABASE_SSL} | |
volumes: | |
- .:/opt/app # Monte le code source dans le conteneur | |
- /opt/app/node_modules # Ignore node_modules local pour éviter les conflits | |
networks: | |
- default | |
depends_on: | |
- db | |
ports: | |
- "1337:1337" | |
db: | |
image: postgres:15-alpine | |
platform: linux/amd64 | |
container_name: postgres | |
restart: unless-stopped | |
environment: | |
POSTGRES_USER: ${DATABASE_USERNAME} | |
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} | |
POSTGRES_DB: ${DATABASE_NAME} | |
volumes: | |
- postgres-data:/var/lib/postgresql/data | |
ports: | |
- "5432:5432" | |
networks: | |
- default | |
volumes: | |
postgres-data: | |
driver: local |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment