Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudolfvesely/4ad6f762eafbe5417f80ff469b690c38 to your computer and use it in GitHub Desktop.
Save rudolfvesely/4ad6f762eafbe5417f80ff469b690c38 to your computer and use it in GitHub Desktop.

I intentionally made it complicated to show various options from docker-compose.

  • build: . will use Dockerfile (in case of Podman this should be Containerfile) to build image. In other words this will run docker build .
  • args will define / overwrite values in ARG in Dockerfile/Containerfile
  • dockerfile: ./foo/bar/containerfile_for_db is used when Dockerfile has different name. In other words this will run docker build --file=foo/bar/containerfile_for_db
$ cat ./something/api.env
NODE_ENV=test
$ cat .env
TAG=v1.5
$ cat docker-compose.yml
version: "3.9"
services:
  webserver:
    # "Dockerfile" is located in the working directory and will be used to build image
    build: .
    # build arguments (used in Dockerfile)
    args:
      APP_HOME: app
    # environment variables
    environment:
      FLASK_ENV: development
  dbserver:
    # "Dockerfile" has different name
    dockerfile: ./foo/bar/containerfile_for_db
    # environment variables in a file
    env_file:
     - ./something/api.env
  redis:
    # variable defined in ".env"
    image: "webapp:${TAG}"
    volumes:
      - logvolume01:/var/log
    ports:
      - "5000:5000"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment