version: "3.3"

services:
  app:
    build:
      context: "./bin/app"
#     args:
#       NEW_PASSWORD: ${NEW_PASSWORD}
    container_name: '${PROJECT_NAME}-app'
    restart: 'always'
    tty: true
#   entrypoint: [ "sh", "service apache2 start && service ssh start" ]
    links:
      - db
    volumes:
      - ${APACHE_PORTS-./config/ports.conf}:/etc/apache2/ports.conf
      - ${VHOST_DIR-./config/vhosts}:/etc/apache2/sites-enabled
      - ${SSHD_CONFIG-./config/sshd_config}:/etc/ssh/sshd_config
      - ${PROJECT_ROOT-./source}:/root/source
    ports:
      - "${HTTP_PORT}:80"
      - "${HTTPS_PORT}:443"
      - "${REACT_PORT}:3000"
      - "${API_PORT}:20000"
      - "${WS_PORT}:21000"
      - "${MISC_PORT}:8888"
  db:
    image: 'mongo'
    container_name: '${PROJECT_NAME}-db'
    restart: 'always'
    environment:
      - MONGO_INITDB_DATABASE=db
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=toor
    volumes:
      - ${MONGO_CONFIG-./config/init-mongo.js}:/docker-entrypoint-initdb.d/init-mongo.js:ro
      - ${MONGO_VOLUME-./mongo-volume}:/data/db
    ports:
      - ${DB_PORT}:27017
    networks:
      - default 
  code-server:
    image: 'codercom/code-server:latest'
    container_name: '${PROJECT_NAME}-code'
    restart: 'always'
#   user: '${UID}:${GID}'
    links:
      - app
      - db
#   environment:
#     - DOCKER_USER=$USER
    volumes:
#     - ${CODE_SERVER_CONFIG-./config/code-server.yaml}:/home/coder/.config/code-server/config.yaml
      - ${PROJECT_ROOT-./source}:/home/coder/source
      - ${CODE_SERVER_CONFIG-./coder-data}:/home/coder/.local/share/code-server
    ports:
      - ${CODE_SERVER_PORT}:8080
