Skip to content

Commit

Permalink
Add new Docker concept
Browse files Browse the repository at this point in the history
  • Loading branch information
piotrkardasz committed Sep 30, 2023
1 parent d2735ad commit 5420ff2
Show file tree
Hide file tree
Showing 19 changed files with 142 additions and 406 deletions.
10 changes: 10 additions & 0 deletions .docker/ports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
services:
mysql:
ports:
- "3306:3306"
nginx:
ports:
- "80:80"
mailhog:
ports:
- "8025:8025"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

/docker-compose.override.yaml
/docker-compose.override.yml
/compose.override.yaml
/compose.override.yml
/docker/mysql/data/

###> symfony/framework-bundle ###
Expand Down
28 changes: 28 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.PHONY: run

DOCKER_USER ?= "$(shell id -u):$(shell id -g)"
ENV ?= "dev"

init:
@if [ ! -e compose.override.yml ]; then \
cp compose.override.dist.yml compose.override.yml; \
fi
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose run --rm php composer install --no-interaction --no-scripts
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose run --rm nodejs
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose run --rm php bin/console sylius:install -s default -n
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose up -d

run:
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose up -d

debug:
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose -f compose.yml -f compose.override.yml -f compose.debug.yml up -d

stop:
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose stop

down:
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose down

clean:
@ENV=$(ENV) DOCKER_USER=$(DOCKER_USER) docker-compose down -v
22 changes: 22 additions & 0 deletions compose.debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
services:
php:
image: piotrkardasz/sylius-php:8.2-fixuid-xdebug-alpine
environment:
APP_DEBUG: 1
MAILER_URL: smtp://mailhog:1025
XDEBUG_MODE: debug
XDEBUG_CONFIG: >-
client_host=host.docker.internal
client_port=9003
log=/dev/stdout
# This should correspond to the server declared in PHPStorm `Preferences | Languages & Frameworks | PHP | Servers`
# Then PHPStorm will use the corresponding path mappings
PHP_IDE_CONFIG: serverName=sylius
extra_hosts:
- "host.docker.internal:host-gateway"
mailhog:
extends:
service: mailhog
file: ./.docker/ports.yaml
# do not use in production!
image: mailhog/mailhog:latest
50 changes: 50 additions & 0 deletions compose.override.dist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
version: "3.8"
services:
php:
image: piotrkardasz/sylius-php:8.2-fixuid-alpine
user: ${DOCKER_USER:-1000:1000}
depends_on:
mysql:
condition: service_healthy
environment:
APP_DEBUG: 1
APP_ENV: ${ENV:-dev}
volumes:
- .:/srv/sylius:rw,cached
# if you develop on Linux, you may use a bind-mounted host directory instead
# - ./var:/srv/sylius/var:rw
- ./public:/srv/sylius/public:rw,delegated
# if you develop on Linux, you may use a bind-mounted host directory instead
# - ./public/media:/srv/sylius/public/media:rw
- public-media:/srv/sylius/public/media:rw
mysql:
extends:
service: mysql
file: ./.docker/ports.yaml
volumes:
- mysql-data:/var/lib/mysql:rw

nginx:
extends:
service: nginx
file: ./.docker/ports.yaml
volumes:
- ./public:/srv/sylius/public:ro
# if you develop on Linux, you may use a bind-mounted host directory instead
# - ./public/media:/srv/sylius/public/media:ro
- public-media:/srv/sylius/public/media:ro,nocopy
nodejs:
image: node:${NODE_VERSION:-16}-alpine
user: ${DOCKER_USER:-1000:1000}
working_dir: /srv/sylius
entrypoint: [ "/bin/sh","-c" ]
command:
- |
yarn install
yarn build
volumes:
- .:/srv/sylius:rw,cached
- ./public:/srv/sylius/public:rw,delegated
volumes:
mysql-data:
public-media:
30 changes: 30 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
services:
php:
image: piotrkardasz/sylius-php:8.2-alpine
environment:
APP_DEBUG: 0
APP_ENV: prod
APP_SECRET: EDITME
# DATABASE_URL: mysql://sylius:${MYSQL_PASSWORD}@mysql/sylius_prod
DATABASE_URL: "mysql://root@mysql/sylius_%kernel.environment%"
MAILER_URL: null://null
MESSENGER_TRANSPORT_DSN: doctrine://default
SYLIUS_MESSENGER_TRANSPORT_MAIN_DSN: doctrine://default
SYLIUS_MESSENGER_TRANSPORT_MAIN_FAILED_DSN: doctrine://default?queue_name=main_failed
SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_DSN: doctrine://default?queue_name=catalog_promotion_removal
SYLIUS_MESSENGER_TRANSPORT_CATALOG_PROMOTION_REMOVAL_FAILED_DSN: doctrine://default?queue_name=catalog_promotion_removal_failed
PHP_DATE_TIMEZONE: ${PHP_DATE_TIMEZONE:-UTC}
mysql:
image: mysql:5.7 # Sylius is fully working on mysql 8.0 version
platform: linux/amd64
healthcheck:
test: '/usr/bin/mysql --execute "SHOW databases;"'
timeout: 3s
interval: 1s
retries: 10
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: 1
cap_add:
- SYS_NICE # prevent "mbind: Operation not permitted" errors
nginx:
image: piotrkardasz/sylius-nginx:latest
118 changes: 0 additions & 118 deletions docker-compose.prod.yml

This file was deleted.

104 changes: 0 additions & 104 deletions docker-compose.yml

This file was deleted.

2 changes: 0 additions & 2 deletions docker/cron/crontab

This file was deleted.

12 changes: 0 additions & 12 deletions docker/cron/docker-entrypoint.sh

This file was deleted.

Loading

0 comments on commit 5420ff2

Please sign in to comment.