services:
  web:
    build: ./app
    ports:
      - "3000:3000"
    # files are put in here
    env_file: ./app/.env
    volumes:
      - ./app:/usr/src/app
      - ./app/node_modules:/usr/src/app/node_modules
    command: ["yarn", "dev"]
  cms:
    container_name: strapi
    build:
      context: ./cms
      dockerfile: Dockerfile
    restart: unless-stopped
    env_file: ./cms/.env
    environment:
      DATABASE_CLIENT: ${DATABASE_CLIENT}
      DATABASE_HOST: ${DATABASE_HOST}
      DATABASE_PORT: ${DATABASE_PORT}
      DATABASE_NAME: ${DATABASE_NAME}
      DATABASE_USERNAME: ${DATABASE_USERNAME}
      DATABASE_PASSWORD: ${DATABASE_PASSWORD}
      ADMIN_JWT_SECRET: ${ADMIN_JWT_SECRET}
      APP_KEYS: ${APP_KEYS}
    volumes:
      - ./cms/config:/opt/app/config
      - ./cms/src:/opt/app/src
      - ./cms/package.json:/opt/package.json
      - ./cms/yarn.lock:/opt/yarn.lock
      - ./cms/.env:/opt/app/.env
      - ./cms/public/uploads:/opt/app/public/uploads
    ports:
      - "1337:1337"
  db:
    container_name: db
    image: postgres:14
    restart: unless-stopped
    environment:
      POSTGRES_USER: ${DATABASE_USERNAME}
      POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
      POSTGRES_DB: ${DATABASE_NAME}
    ports:
      - "5432:5432"
    volumes: #mirror where postgres put their data
      - ./db:/var/lib/postgresql/data
