Skip to content

Commit

Permalink
Mount all directories in dev environment (#206)
Browse files Browse the repository at this point in the history
Mount all directories with the following exceptions #58:
* Each container maintains a separate set of files in /var to avoid
permission issues. Files aren't shared with the host system.
* /vendor stays a shared named volume. Files need to be copied to
the host system.

Additional fixes:
* Use correct paths in .dockerignore.
* Create assets directory explicitly to show that it's a used path.
  • Loading branch information
marein authored Jan 2, 2024
1 parent 41e68c4 commit c43b4f9
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/var
/vendor
/web/assets
/public/assets
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
/tests/acceptance.suite.yml
/tests/unit.suite.yml
/vendor
/web/assets
40 changes: 11 additions & 29 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
version: '3.4'

x-php-container-volumes:
&php-container-volumes
volumes:
- ./:/project:delegated
- vendor:/project/vendor
- proxysql.sock:/var/run/proxysql
- type: tmpfs
target: /project/var

x-php-container:
&php-container
<<: *php-container-volumes
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
Expand All @@ -12,11 +22,6 @@ x-php-container:
- redis
- rabbit-mq
- nchan
volumes:
- ./config:/project/config:delegated
- ./src:/project/src:delegated
- vendor:/project/vendor
- proxysql.sock:/var/run/proxysql
restart: on-failure

services:
Expand Down Expand Up @@ -159,15 +164,6 @@ services:
- "prometheus-port=81"
php-fpm:
<<: *php-container
volumes:
- ./assets:/project/assets:delegated
- ./config:/project/config:delegated
- ./src:/project/src:delegated
- ./tests:/project/tests:delegated
- ./var:/project/var:delegated
- ./web:/project/web:delegated
- vendor:/project/vendor
- proxysql.sock:/var/run/proxysql
labels:
- "traefik.enable=true"
- "traefik.http.routers.php-fpm.priority=10"
Expand Down Expand Up @@ -197,26 +193,12 @@ services:
# Development helper #
##############################
php:
<<: *php-container-volumes
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
entrypoint: ''
command: 'true'
volumes:
- ./src:/project/src:delegated
- ./tests:/project/tests:delegated
- vendor:/project/vendor
composer:
build:
context: .
dockerfile: ./docker/php-fpm/Dockerfile
target: builder
entrypoint: ''
command: 'true'
volumes:
- ./composer.json:/project/composer.json
- ./composer.lock:/project/composer.lock
- vendor:/project/vendor
phpmyadmin:
image: phpmyadmin/phpmyadmin:5.2
environment:
Expand Down
10 changes: 5 additions & 5 deletions project
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ build() {
docker compose pull
docker compose down --volumes
docker compose build --pull
docker compose up -d composer
docker cp "$(docker compose ps -q composer)":/project/vendor ./
docker compose up -d php
docker cp "$(docker compose ps -aq php | head -n 1)":/project/vendor ./
docker compose up --remove-orphans
}

Expand All @@ -60,9 +60,9 @@ down() {
}

composer() {
docker compose up -d composer
docker compose run composer composer "$@"
docker cp "$(docker compose ps -q composer)":/project/vendor ./
docker compose up -d php
docker compose run --rm php composer "$@"
docker cp "$(docker compose ps -aq php | head -n 1)":/project/vendor ./
}

tests() {
Expand Down
2 changes: 2 additions & 0 deletions public/assets/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/*
!.gitignore

0 comments on commit c43b4f9

Please sign in to comment.