Skip to content

Instantly share code, notes, and snippets.

@gbarreiro
Last active February 17, 2021 14:56
Show Gist options
  • Save gbarreiro/775f111453d88b220d2fb1963e5ab08c to your computer and use it in GitHub Desktop.
Save gbarreiro/775f111453d88b220d2fb1963e5ab08c to your computer and use it in GitHub Desktop.
Docker Compose sample file
version: "3.8"
services:
database:
image: mysql:latest
volumes:
- db-data:/var/lib/mysql/data
command: --default-authentication-plugin=mysql_native_password # run this command in the container
networks:
- database-api
restart: always # the container must be always on
env_file:
- mysql.env # inject the environment variables defined in the file "mysql.env"
api:
build: ./node # use the Dockerfile in the folder "node" for creating the image for this container
networks:
- database-api
- frontend-api
depends_on: # the container won't be started until the "database" container is running
- database
restart: unless-stopped # the container will be always on unless it was manually stopped
frontend:
image: httpd
ports:
- "1234:80" # map the container port 80 to the host port 1234
networks:
- frontend-api
volumes:
- ./htdocs:/var/www/html
depends_on: # the container won't be started until the "api" container is running
- api
environment:
AllowOverride: None # set an environment variable for the container
restart: unless-stopped # the container will be always on unless it was manually stopped
volumes:
db-data:
networks:
database-api:
frontend-api:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment