version: "3"

# Please note that, this docker-compose is only for test latest image built
# from development branch and prod image built from released version.
# Before launching database and Nitrate images, make sure the image is built by
# `make image' with proper tag.
#
# If you would like to launch Nitrate for development purpose, please use
# `docker-compose-dev.yml`.

services:
  db:
    image: "mariadb:10.4.14"
    volumes:
    - "nitrate_db_data:/var/lib/mysql"
    restart: always
    environment:
    - MYSQL_DATABASE=nitrate
    - MYSQL_ALLOW_EMPTY_PASSWORD=yes
    command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci

  web:
    depends_on:
    - db
    restart: always
    image: "${DOCKER_ORG:-quay.io/nitrate}/nitrate:${IMAGE_VERSION:-latest}"
    ports:
    - "8001:80"
    volumes:
    - "nitrate_uploads:/code/uploads"
    - "nitrate_httpd_logs:/var/log/httpd"
    environment:
      NITRATE_DB_ENGINE: mysql
      NITRATE_DB_HOST: db
      NITRATE_DB_PORT: 3306
      NITRATE_DB_NAME: nitrate
      NITRATE_DB_USER: root

# Run `docker inspect web` to see volume directory on host.

volumes:
  nitrate_db_data:
  nitrate_uploads:
  nitrate_httpd_logs:
