Skip to content
Snippets Groups Projects
docker-compose.yml 2.75 KiB
Newer Older
# This is an example with common values.
# Depending on the context, you may no have
# to use them all : maybe you don't need
# volumes of Traefik, feel free to remove
# everything you don't need or understand
# to suit your needs.
# Don't hesitate to ask to the tech team.

  # Declaration of Docker volume
Quentin Duchemin's avatar
Quentin Duchemin committed
  # Also use a name so that Docker Compose does not add
  # the current folder name
  # Use as many volumes as you want : one for
  # data, one for configuration, etc.
  data:
    name: data
  # Best pratice : put all services that do not need
  # to be exposed on the Internet in a separate network
Quentin Duchemin's avatar
Quentin Duchemin committed
  app:
  # This is the reverse-proxy default network : put all services
  # that need to be served via Traefik in this network
  docker_default:
    external: true

services:
Quentin Duchemin's avatar
Quentin Duchemin committed
  # Main application
  app:
    # This is the name of the image
    # which will be built on the registry
    # Never use latest as a tag
    image: registry.picasoft.net/<image>:<tag>
    # Use a comprehensive name for easy
    # understanding of `docker ps` output
    container_name: app
    # If the container has to be reached from
    # the Internet, put in docker_default
    # Otherwise, just in its own network
    networks:
      - docker_default
      - app
    volumes:
      # Mount the Docker Volume in the container
      # to persist the data. The mount point
      # is service-dependant.
      - data:/mount_point
      # Exemple of mounting a file for configuration.
      # This is not a Docker volume, but a versionned
      # file is this repository.
      - ./config.json:/config.json
Quentin Duchemin's avatar
Quentin Duchemin committed
    # Don't put the .example extension, the real
    # file will be a copy with real values
    env_file:
      - ./secrets/myservices.secrets
    # If the service needs to be reachable from the
    # Internet via HTTPS, enable Traefik and tell
    # it the base URL of all requests which will be
    # redirected to this container.
    # Change the port to the exposed port of the
    # container.
    labels:
      traefik.enable: true
      traefik.frontend.rule: "Host:app.picasoft.net"
      traefik.port: 80
    # If the service has a database,
    # tell Compose that it depends on it (i.e.)
    # should be launched if the service is launched
    depends_on:
      - db
Quentin Duchemin's avatar
Quentin Duchemin committed
    # This avoid restarting a container on
    # startup when it has been explicitly stopped
    restart: unless-stopped

  # Some services have a database : here is an example
  db:
    image: registry.picasoft.net/<image>:<tag>
    container_name: db
    # Database secrets should be in a separate file
    env_file:
      - ./secrets/myservices_db.secrets
    # The database should NOT be reachable
    # from the outside : only from the main container
    networks:
      - app
    restart: unless-stopped