version: "3"
# docker compose -f ./infra/docker-compose.yml up
#
# Run front end code (frontend service) AND backend (server service) locally (so I can debug them) and run Keycloak and Postgres in Docker with:
# docker compose -f ./infra/docker-compose.yml up keycloak postgres --no-deps
services:
postgres:
image: postgres
volumes:
- /var/lib/postgres-keycloak-and-ep:/var/lib/postgres-keycloak-and-ep/data
environment:
POSTGRES_DB: "postgres"
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "password"
PGDATA: "/var/lib/postgres-keycloak-and-ep/data"
healthcheck:
test: ["CMD-SHELL", "pg_isready -U postgres -d postgres"]
interval: 10s
timeout: 5s
retries: 5
start_period: 5s
ports:
- "5432:5432"
# for debugging statements
command: ["postgres", "-c", "log_statement=all"]
keycloak:
depends_on:
postgres:
condition: service_healthy
server:
condition: service_started
build:
context: ../keycloak
dockerfile: ./keycloak-localhost.dockerfile
environment:
KC_DB_URL_DATABASE: "postgres"
# Many environment variables are set in my custom keycloak-localhost.dockerfile - I have copied them here and simplified a bit. The syntax might not be 100% correct since .dockerfile syntax is a bit different
ENV KC_DB: "postgres"
ENV KC_DB_USERNAME: "postgres"
ENV KC_DB_PASSWORD: "password"
# ENV KC_DB_SCHEMA: "public"
# ENV KC_DB_URL_HOST: "postgres"
# ENV KC_DB_URL_PORT: "5432"
# ENV KC_HOSTNAME: "localhost"
# ENV KC_HOSTNAME_PORT: 8443
# ENV KC_HOSTNAME_STRICT: false
# ENV KC_HOSTNAME_STRICT_BACKCHANNEL: false
# ENV KC_HTTP_ENABLED: false
# ENV KC_HTTPS_PROTOCOLS: "TLSv1.3,TLSv1.2"
# ENV KC_HEALTH_ENABLED: true
# ENV KC_LOG: console
# ENV KEYCLOAK_ADMIN: "admin"
# ENV KEYCLOAK_ADMIN_PASSWORD: "admin"
ports:
- "8443:8443"
server:
image: [our app image]
depends_on:
postgres:
condition: service_healthy
build:
context: ../../src/server-code
dockerfile: ./path/to/server/Dockerfile
environment:
ISLOCALHOST: true
ISDOCKER: true
DBUsername: "postgres"
DBPassword: "postgres"
ports:
- "5000:80"
frontend:
image: [our fe image]
build:
context: ../../src/client-code
dockerfile: ./path/to/client/Dockerfile
ports:
- "8080:3000"
volumes:
postgres_data:
driver: local