Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Merge branch 'ntr/docker-sync' into '6.1'
Browse files Browse the repository at this point in the history
Switch to use Docker Volumes, instead of Mount Binds

See merge request shopware/6/product/development!91
  • Loading branch information
pweyck committed Jan 9, 2020
2 parents 4a1f9bd + 378a4e0 commit d161be8
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,8 @@ SHOPWARE_ES_INDEX_PREFIX=__SHOPWARE_ES_INDEX_PREFIX__

SHOPWARE_HTTP_CACHE_ENABLED=__SHOPWARE_HTTP_CACHE_ENABLED__
SHOPWARE_HTTP_DEFAULT_TTL=__SHOPWARE_HTTP_DEFAULT_TTL__
DOCKER_SYNC_ENABLED=__DOCKER_SYNC_ENABLED__
USER_ID=__USER_ID__
GROUP_ID=__GROUP_ID__

__FEATURES__
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/public/assets/*

/files/*

/.docker-sync/
/dev-ops/docker/_volumes/*
/dev-ops/analyze/node_modules
/dev-ops/analyze/vendor
Expand Down
10 changes: 10 additions & 0 deletions .psh.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const:
SHOPWARE_ES_INDEX_PREFIX: "sw"
SHOPWARE_HTTP_CACHE_ENABLED: "0"
SHOPWARE_HTTP_DEFAULT_TTL: 7200
DOCKER_SYNC_ENABLED: false
FEATURES: |
FEATURE_NEXT_516=1
DEVPORT: "8080"
Expand All @@ -58,11 +59,20 @@ dynamic:
E2E_ENV: if [ -z "$(grep docker /proc/self/cgroup)" ]; then echo "default"; else echo "docker"; fi
PROJECT_ROOT: echo `pwd`
COMPOSER_HOME: echo ${COMPOSER_HOME:-"$HOME/.composer"}
DOCKER_APP_VOLUME_MOUNT: echo ".:/app"
DOCKER_APP_VOLUMES: echo ""

environments:
docker:
paths:
- "dev-ops/docker/actions"
dynamic:
DOCKER_APP_VOLUME_MOUNT: |
DOCKER_SYNC_ENABLED=$(grep DOCKER_SYNC_ENABLED .env | xargs); DOCKER_SYNC_ENABLED=${DOCKER_SYNC_ENABLED#*=};
if [[ ${DOCKER_SYNC_ENABLED} ]]; then echo "app_server:/app:nocopy"; else echo ".:/app"; fi
DOCKER_APP_VOLUMES: |
DOCKER_SYNC_ENABLED=$(grep DOCKER_SYNC_ENABLED .env | xargs); DOCKER_SYNC_ENABLED=${DOCKER_SYNC_ENABLED#*=};
if [[ ${DOCKER_SYNC_ENABLED} ]]; then echo "volumes:\n app_server:\n external: true"; else echo ""; fi
templates:
- source: ".env.dist"
destination: ".env"
Expand Down
5 changes: 3 additions & 2 deletions dev-ops/docker/actions/start.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env bash


# check that the ~/.npm and ~/.composer folder are not owned by the root user
dev-ops/docker/scripts/check_permissions.sh

docker-compose build && docker-compose up -d
# Start docker-sync
if [[ -n "__DOCKER_SYNC_ENABLED__" ]]; then docker-sync start && echo "\n docker-sync is initially indexing files. It may take some minutes, until code changes take effect"; fi

docker-compose build && docker-compose up -d
3 changes: 3 additions & 0 deletions dev-ops/docker/actions/stop.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env bash

# Stop docker-sync
if [[ -n "__DOCKER_SYNC_ENABLED__" ]]; then docker-sync stop; fi

docker-compose down
9 changes: 9 additions & 0 deletions dev-ops/docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ version: "3.7"

services:
app_server:
image: shopware/development:local
build:
context: dev-ops/docker/containers/app
args:
USER_ID: __USER_ID__
GROUP_ID: __GROUP_ID__
volumes:
- __DOCKER_APP_VOLUME_MOUNT__
- ~/.npm:/.npm
environment:
CONTAINER_UID: __USER_ID__
Expand Down Expand Up @@ -34,3 +41,5 @@ services:
ports:
- "9200:9200"
- "9300:9300"

__DOCKER_APP_VOLUMES__
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ services:
extra_hosts:
- "docker.vm:127.0.0.1"
volumes:
- .:/app
- ~/.composer:/.composer
tmpfs:
- /tmp:mode=1777
Expand Down
11 changes: 11 additions & 0 deletions docker-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"

options:
max-attempt: 30

syncs:
app_server:
src: './'
sync_excludes: ['.git', '.idea', 'dev-ops/docker/_volumes', 'var', '.docker-sync']
sync_userid: $USER_ID
sync_groupid: $GROUP_ID

0 comments on commit d161be8

Please sign in to comment.