Skip to content

Instantly share code, notes, and snippets.

@elvinlari
Last active July 31, 2023 09:10
Show Gist options
  • Save elvinlari/dcb117e2e8238ce79efcb7193e58ebe6 to your computer and use it in GitHub Desktop.
Save elvinlari/dcb117e2e8238ce79efcb7193e58ebe6 to your computer and use it in GitHub Desktop.
Docker Compose yaml file
version: '3'
networks:
laravel:
services:
nginx:
build:
context: ./docker
dockerfile: nginx.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
restart: unless-stopped
container_name: nginx
ports:
- 8000:8000
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
depends_on:
- php
- redis
- mysql
- laravel-queue
- laravel-cron
- phpmyadmin
- mailhog
networks:
- laravel
php:
build:
context: ./docker
dockerfile: php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: php
ports:
- ":9000"
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
networks:
- laravel
mysql:
image: mariadb:10.6
container_name: mysql
restart: unless-stopped
tty: true
ports:
- 3307:3306
environment:
MYSQL_DATABASE: ${DB_DATABASE}
MYSQL_USER: ${DB_USERNAME}
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_PASSWORD}
SERVICE_TAGS: dev
SERVICE_NAME: mysql
volumes:
- ./docker/mysql:/var/lib/mysql
networks:
- laravel
redis:
image: redis:alpine
container_name: redis
restart: unless-stopped
ports:
- 6380:6379
networks:
- laravel
laravel-cron:
build:
context: ./docker
dockerfile: php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: laravel-cron
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
depends_on:
- mysql
working_dir: /var/www/html
entrypoint: ['php', '/var/www/html/artisan', 'schedule:work']
networks:
- laravel
laravel-queue:
build:
context: ./docker
dockerfile: php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: laravel-queue
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
depends_on:
- mysql
working_dir: /var/www/html
entrypoint: ['php', '/var/www/html/artisan', 'queue:work']
networks:
- laravel
mailhog:
image: mailhog/mailhog:latest
container_name: mailhog
logging:
driver: 'none'
ports:
- 1025:1025
- 8025:8025
networks:
- laravel
phpmyadmin:
image: phpmyadmin:5.2.0
container_name: phpmyadmin
environment:
PMA_ARBITRARY: 1
PMA_HOST: ${DB_HOST}
PMA_USER: ${DB_USERNAME}
PMA_PASSWORD: ${DB_PASSWORD}
PMA_PORT: ${DB_PORT}
depends_on:
- mysql
ports:
- 8888:80
networks:
- laravel
laravel-migrate-seed:
build:
context: ./docker
dockerfile: php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: laravel-migrate-seed
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
depends_on:
- mysql
profiles: ["migrate-seed"]
working_dir: /var/www/html
entrypoint: ["/bin/sh","-c"]
command:
- |
php artisan migrate
php artisan db:seed
networks:
- laravel
composer:
build:
context: ./docker
dockerfile: composer.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: composer
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
working_dir: /var/www/html
depends_on:
- php
user: ${USER:-laravel} #system user
profiles: ["composer"]
entrypoint: ['composer', '--ignore-platform-reqs']
networks:
- laravel
artisan:
build:
context: ./docker
dockerfile: php.dockerfile
args:
- UID=${UID:-1000}
- GID=${GID:-1000}
- USER=${USER:-laravel}
container_name: artisan
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
depends_on:
- mysql
working_dir: /var/www/html
profiles: ["artisan"]
entrypoint: ['php', '/var/www/html/artisan']
networks:
- laravel
npm:
image: node:alpine
container_name: npm
volumes:
- ./src:/var/www/html
- .env:/var/www/html/.env
ports:
- 3000:3000
- 3001:3001
working_dir: /var/www/html
profiles: ["npm"]
entrypoint: ['npm']
networks:
- laravel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment