fix: Docker compose configuration

This commit is contained in:
Simon C 2024-02-08 14:28:28 +01:00
parent 674d58d5b9
commit afe39cc5c8
5 changed files with 52 additions and 22 deletions

View File

@ -1,28 +1,37 @@
#
# Docker
#
#COMPOSE_FILE=docker-compose.yml:docker-compose.traefik.yml
COMPOSE_FILE=docker-compose.yml:docker-compose.local.yml
OPENDATA_NETWORK_NAME=opendata
#
# PostgreSQL
#
POSTGRES_CONTAINER_NAME=postgres
POSTGRES_IMAGE=postgres:latest
POSTGRES_IMAGE=postgres:16.1
POSTGRES_VOLUME_NAME=postgres
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_PASSWORD=utiliser-la-commande-pour-generer-un-mot-de-passe # tr -cd '[:alnum:]' < /dev/urandom | fold -w "64" | head -n 1 | tr -d '\n' ; echo
POSTGRES_DB=postgres
DB_ANON_ROLE=anon
DB_SCHEMA=public
PGADMIN_USER=postgres@postgres.org
PGADMIN_PASSWORD=postgres
#
# PostgREST
#
POSTGREST_URL=https://opendata.example.org/
POSTGREST_DOMAIN=localhost
POSTGREST_CONTAINER_NAME=postgrest
POSTGREST_IMAGE=postgrest/postgrest:v12.0.2
POSTGREST_URL=http://${POSTGREST_DOMAIN}:3000/
PGRST_DB_MAX_ROWS=100
@ -30,6 +39,14 @@ PGRST_DB_MAX_ROWS=100
# Swagger UI
#
SWAGGER_URL=https://ui.opendata.example.org/
SWAGGER_DOMAIN=ui.opendata.example.org
SWAGGER_CONTAINER_NAME=swagger
SWAGGER_IMAGE=swaggerapi/swagger-ui:v5.11.0
#
# Traefik
#
TRAEFIK_NETWORK_NAME=traefik
TRAEFIK_ROUTER_NAME=opendata
TRAEFIK_ENTRYPOINTS=websecure

View File

@ -2,28 +2,16 @@
version: "3.8"
networks:
front-end:
back-end:
driver: bridge
services:
postgres:
ports:
- "5432:5432"
networks:
- back-end
postgrest:
ports:
- "3000:3000"
networks:
- back-end
swagger:
ports:
- "8080:8080"
networks:
- front-end
- back-end

View File

@ -6,14 +6,26 @@ networks:
traefik:
name: ${TRAEFIK_NETWORK_NAME:-traefik}
external: true
opendata:
name: ${OPENDATA_NETWORK_NAME:-opendata}
services:
postgrest:
networks:
- traefik
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_NETWORK_NAME:-traefik}
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_postgrest.rule=Host(`${POSTGREST_DOMAIN:?err}`)
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_postgrest.entrypoints=${TRAEFIK_ENTRYPOINTS:-websecure}
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_postgrest.tls.certResolver=letsencrypt
swagger:
networks:
- traefik
- traefik
labels:
- traefik.enable=true
- traefik.docker.network=${TRAEFIK_NETWORK_NAME:-traefik}
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_swagger.rule=Host(`${SWAGGER_DOMAIN:?err}`)
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_swagger.entrypoints=${TRAEFIK_ENTRYPOINTS:-websecure}
- traefik.http.routers.${TRAEFIK_ROUTER_NAME:-opendata}_swagger.tls.certResolver=letsencrypt
- traefik.http.services.${TRAEFIK_ROUTER_NAME:-opendata}_swagger.loadbalancer.server.port=8080

View File

@ -2,6 +2,10 @@
version: "3.8"
networks:
opendata:
name: ${OPENDATA_NETWORK_NAME:-opendata}
volumes:
postgres:
name: ${POSTGRES_VOLUME_NAME:-postgres}
@ -23,6 +27,8 @@ services:
- "./initdb:/docker-entrypoint-initdb.d"
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
- opendata
postgrest:
container_name: ${POSTGREST_CONTAINER_NAME:-postgrest}
@ -38,6 +44,8 @@ services:
PGRST_DB_MAX_ROWS: ${PGRST_DB_MAX_ROWS:-100}
depends_on:
- postgres
networks:
- opendata
swagger:
container_name: ${SWAGGER_CONTAINER_NAME:-swagger}
@ -45,3 +53,7 @@ services:
restart: always
environment:
API_URL: ${POSTGREST_URL:-http://localhost:3000/}
depends_on:
- postgrest
networks:
- opendata

View File

@ -1,4 +1,5 @@
{
"name": "opendata",
"type": "module",
"scripts": {
"clean": "rm ./node_modules -rf && rm ./tmp -rf && rm ./initdb/*.csv -rf",