Skip to main content

generale

Container Naming

The name should be univocal, in order to be immediately identifiable, better to put the name of the project, the environment (dev, coll, prod, prelive, etc.)

preferably: <teamname>-<projectname>-<servicename>-<env>

example

  web-app:
    image: gitlab-registry.eagleprojects.cloud/python/rpa/rpa-1942_webapp_hr:latest-dev
    restart: unless-stopped
    container_name: rpa-hr-web-app-dev  <-- OK!
    ports:
      - '24406:8000'
    volumes:
      - ./shared-data:/app/downloads
    env_file:
      - .env
    depends_on:
      - redis
      - db
    environment:
      - "TZ=Europe/Rome"
    labels:
      - 'com.centurylinklabs.watchtower.enable=true'
      - "cloud.eagleprojects.autocd.enable=true"

  web-app:
    image: gitlab-registry.eagleprojects.cloud/python/rpa/rpa-1942_webapp_hr:latest-dev
    restart: unless-stopped
    container_name: web-app <-- NOT GOOD!
    ports:
      - '24406:8000'
    volumes:
      - ./shared-data:/app/downloads
    env_file:
      - .env
    depends_on:
      - redis
      - db
    environment:
      - "TZ=Europe/Rome"
    labels:
      - 'com.centurylinklabs.watchtower.enable=true'
      - "cloud.eagleprojects.autocd.enable=true"

Ports

It would be good to use doors on display on the host (therefore ports, not exposure) greater than 23000 and lower than the 65000 included

example

  web-app:
    image: gitlab-registry.eagleprojects.cloud/python/rpa/rpa-1942_webapp_hr:latest-dev
    restart: unless-stopped
    container_name: hr-web-app-dev
    ports:           <--
      - '24406:8000' <-- OK!
    volumes:
      - ./shared-data:/app/downloads
    env_file:
      - .env
    depends_on:
      - redis
      - db
    environment:
      - "TZ=Europe/Rome"
    labels:
      - 'com.centurylinklabs.watchtower.enable=true'

Timezone

It is important to also put the timezone as Environment, as in the examples above

Healthcheck

Where possible to add a Healthcheck

    healthcheck:
      test: ["CMD-SHELL", "curl localhost:8080"]
      interval: "10s"
      timeout: "30s"
      retries: 5
      start_period: "20s"

Password

The passwords where possible must be longer than 16 characters, in order to avoid incompatibility with some systems it would be good to use only numbers and letters, therefore better to avoid symbols, if it is essential to use symbols in any case categorically avoid characters: # @ ! & ; / > < % *

Env

As for the names of Env files, the standard agreement is the following. If only one ENV file must be called .env. In the case of multiple files (for example to provide the access credentials to the DB to the BE only), then the files will be called

or

.env-be .env-fe .env-db ecc

or

.env-<servizio> es: .env-postgres_16 .env-redis_lts

The first nomenclature is preferable. Regardless of the ENV files, they must be in the same level as Docker-comparison.

├── depa-fe-asset
│   ├── config.conf
│   └── img
│       └── test.png
├── docker-compose.yaml   <--------
├── .env-be                <--------
└── .env-fe                <--------