Skip to content

Instantly share code, notes, and snippets.

@pekhota
Created April 7, 2020 16:35
Show Gist options
  • Save pekhota/6c773de8b81cec49d798402de57e1e3b to your computer and use it in GitHub Desktop.
Save pekhota/6c773de8b81cec49d798402de57e1e3b to your computer and use it in GitHub Desktop.
Good starting docker-compose for laravel project
version: "3.7"
services:
# todo run as non root user
nginx:
# using alpine for better image size
# using exact version for backward compatibility
# https://hub.docker.com/_/nginx
image: "nginx:1.17.9-alpine"
volumes:
- ./docker/nginx/server.conf:/etc/nginx/conf.d/default.conf
- ./docker/nginx/pma.conf:/etc/nginx/conf.d/pma.conf
- ./:/app
- pma:/var/www/html
ports:
- "8080:80" # fpm
- "8090:8090" # pma
# https://docs.docker.com/compose/compose-file/#restart
restart: unless-stopped
depends_on:
- fpm
- pma
fpm:
# https://hub.docker.com/_/php
image: "php:7.4-fpm-alpine"
volumes:
- ./:/app
depends_on:
- redis
restart: unless-stopped
redis:
# https://hub.docker.com/_/redis
image: "redis:5.0.8-alpine"
restart: unless-stopped
volumes:
- redis:/data
db:
# todo diff v8 vs v5.7
# https://hub.docker.com/_/mysql/
image: "mysql:8.0.19"
command: --default-authentication-plugin=mysql_native_password
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_DATABASE: "${DB_DATABASE}"
MYSQL_USER: "${DB_USERNAME}" # !!! do not use root user
MYSQL_PASSWORD: "${DB_PASSWORD}"
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
pma:
# https://hub.docker.com/r/phpmyadmin/phpmyadmin
image: "phpmyadmin/phpmyadmin:5.0.2-fpm-alpine"
environment:
PMA_HOST: db
volumes:
- pma:/var/www/html
depends_on:
- db
volumes:
mysql:
driver: local
redis:
driver: local
pma:
driver: local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment