Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove docker-sync support #530

Merged
merged 1 commit into from
Jan 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions src/_base/_twig/docker-compose.yml/service/console.yml.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% set blocks = '_twig/docker-compose.yml/' %}
{% set syncvolume = false %}
{% if @('host.os') == 'darwin' and @('docker-sync') == 'yes' %}
{% set syncvolume = true %}
{% elseif @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% if @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% set syncvolume = true %}
{% endif %}

Expand Down
4 changes: 1 addition & 3 deletions src/_base/_twig/docker-compose.yml/service/nginx.yml.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{% set syncvolume = false %}
{% if @('host.os') == 'darwin' and @('docker-sync') == 'yes' %}
{% set syncvolume = true %}
{% elseif @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% if @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% set syncvolume = true %}
{% endif %}
{% set hostnames = [@('hostname')] %}
Expand Down
4 changes: 1 addition & 3 deletions src/_base/_twig/docker-compose.yml/service/php-fpm.yml.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% set blocks = '_twig/docker-compose.yml/' %}
{% set syncvolume = false %}
{% if @('host.os') == 'darwin' and @('docker-sync') == 'yes' %}
{% set syncvolume = true %}
{% elseif @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% if @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% set syncvolume = true %}
{% endif %}

Expand Down
34 changes: 4 additions & 30 deletions src/_base/application/skeleton/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -179,35 +179,25 @@ then enable Xdebug using either `ws feature xdebug on` or `ws feature xdebug cli

### Performance on macOS

Page load times with Docker for Mac can vary considerably due to the sharing of files from the macOS disk to the small
Page load times with Docker Desktop for Mac can vary considerably due to the sharing of files from the macOS disk to the small
virtual machine that docker is running inside.
This is especially so when there is a large quantity of small files, such as with a large composer node_modules or
vendor folder.

[Mutagen](https://mutagen.io/documentation/transports/docker) and
[docker-sync](https://github.com/EugenMayer/docker-sync/) are tools to synchronise files between host machine and
[Mutagen](https://mutagen.io/documentation/transports/docker) is a tool to synchronise files between host machine and
docker containers.
They both enable production-like performance at the cost of having to synchronise files with an intermediate
It enables production-like performance at the cost of having to synchronise files with an intermediate
"data" container.

{% if @('mutagen') == 'yes' %}
Mutagen is enabled on the development environment.
You can switch to docker-sync if you wish with `ws switch docker-sync`.
{% elseif @('docker-sync') == 'yes' %}
docker-sync is enabled on the development environment.
You can switch to mutagen if you wish with `ws switch mutagen`.
{% else %}
If it takes over 2 seconds to load a page, you should consider enabling mutagen or docker-sync by adding the following
If it takes over 2 seconds to load a page, you should consider enabling mutagen by adding the following
to `workspace.override.yml` in the project root, or after testing it and the whole team would like to use it,
`workspace.yml` in the project root:

```yaml
# for mutagen:
attribute('docker-sync'): 'no'
attribute('mutagen'): 'yes'
# or for docker-sync:
attribute('docker-sync'): 'yes'
attribute('mutagen'): 'no'
```

Then running `ws harness prepare && ws disable && ws enable`.
Expand All @@ -224,14 +214,6 @@ mutagen monitor
# To debug a sync error
mutagen list
```
{% if @('docker-sync') == 'yes' %}

Useful commands for docker-sync:
```bash
# Check the logs
docker-sync logs -f
```
{% endif %}

### Common Issues

Expand All @@ -244,14 +226,6 @@ As setup issues are encountered please detail with step by step fix instructions
* Head to Docker Desktop Preferences via the system tray icon
* Turn off "Enable cloud experience" under the Command Line area of Preferences
* Click the "Apply and restart" button
* If you use docker-sync and notice that your changes aren't synchronising to the environment:
* Check if your file exists with your changes in `ws console`
* If your file in `ws console` has changed okay, check your project for any caching that
would prevent changes to source code appearing immediately.
* If the file changes do not appear in `ws console` reasonably quickly, it might be that
Docker for Mac is overwhelmed with file change events.
* Restarting Docker for Mac using the system tray icon's menu and then running `ws enable` again
will fix it.

# License

Expand Down
4 changes: 1 addition & 3 deletions src/_base/docker-compose.yml.twig
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{% set blocks = '_twig/docker-compose.yml/' %}
{% set syncvolume = false %}
{% if @('host.os') == 'darwin' and @('docker-sync') == 'yes' %}
{% set syncvolume = true %}
{% elseif @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% if @('host.os') == 'darwin' and @('mutagen') == 'yes' %}
{% set syncvolume = true %}
{% endif %}
version: '{{ @('docker.compose.file_version') }}'
Expand Down
16 changes: 0 additions & 16 deletions src/_base/docker-sync.yml.twig

This file was deleted.

3 changes: 1 addition & 2 deletions src/_base/harness/attributes/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ attributes.default:
vendor_directory: /app/vendor

delegated-volumes: no
docker-sync: no
mutagen: yes

jenkins:
Expand Down Expand Up @@ -157,7 +156,7 @@ attributes.default:
default_branch: = @('git.main_branch')
# potentially deprecated, unless it is repurposed
main_branch: develop

lighthouse:
target:
url: = @('hostname')
Expand Down
23 changes: 0 additions & 23 deletions src/_base/harness/config/commands.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

command('enable'):
env:
USE_DOCKER_SYNC: = @('host.os') == 'darwin' and @('docker-sync') == 'yes' ? 'yes':'no'
USE_MUTAGEN: = @('host.os') == 'darwin' and @('mutagen') == 'yes' ? 'yes':'no'
APP_BUILD: = @('app.build')
APP_MODE: = @('app.mode')
Expand All @@ -14,7 +13,6 @@ command('enable'):

command('disable'):
env:
USE_DOCKER_SYNC: = (@('host.os') == 'darwin' and @('docker-sync') == 'yes') ? 'yes':'no'
USE_MUTAGEN: = @('host.os') == 'darwin' and @('mutagen') == 'yes' ? 'yes':'no'
NAMESPACE: = @('namespace')
COMPOSE_PROJECT_NAME: = @('namespace')
Expand All @@ -28,7 +26,6 @@ command('destroy'):
APP_BUILD: = @('app.build')
APP_VERSION: = @('app.version')
DOCKER_REPOSITORY: = @('docker.repository')
USE_DOCKER_SYNC: = (@('host.os') == 'darwin' and @('docker-sync') == 'yes') ? 'yes':'no'
USE_MUTAGEN: = @('host.os') == 'darwin' and @('mutagen') == 'yes' ? 'yes':'no'
COMPOSE_PROJECT_NAME: = @('namespace')
exec: |
Expand Down Expand Up @@ -110,26 +107,6 @@ command('assets upload'):
#!bash(workspace:/)|@
passthru ws.aws s3 sync '@('assets.local')' '@('assets.remote')'

command('feature docker-sync (on|off)'):
env:
ATTR_KEY: 'docker-sync'
ATTR_VAL: = input.command(3) == 'on' ? 'yes':'no'
exec: |
#!bash(workspace:/)|=
ws set $ATTR_KEY $ATTR_VAL
echo 'Updating docker-compose.yml'
run ws install --step=prepare
echo 'Bringing up the environment with the new setting'
if [[ "$ATTR_VAL" = "yes" ]]; then
passthru ws docker-sync start
fi
passthru ws enable
if [[ "$ATTR_VAL" = "no" ]]; then
passthru ws docker-sync stop
passthru ws docker-sync clean
fi
echo 'Done'

command('frontend build'):
env:
COMPOSE_PROJECT_NAME: = @('namespace')
Expand Down
1 change: 0 additions & 1 deletion src/_base/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ confd('harness:/'):
- { src: application/skeleton/README.md }
- { src: mutagen.yml, dst: workspace:/mutagen.yml } # docker-compose.yml render reads this file
- { src: docker-compose.yml, dst: workspace:/docker-compose.yml }
- { src: docker-sync.yml, dst: workspace:/docker-sync.yml }
- { src: harness/scripts/enable.sh }
- { src: helm/app/_twig/templates/service/varnish/configmap.yaml, dst: harness:/helm/app/templates/service/varnish/configmap.yaml }
- { src: helm/app/values.yaml }
Expand Down
8 changes: 0 additions & 8 deletions src/_base/harness/config/docker-sync.yml

This file was deleted.

12 changes: 1 addition & 11 deletions src/_base/harness/config/mutagen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ command('mutagen rm'):
CONTAINER_NAMES=($CONTAINER_NAMES)
passthru docker volume rm "${CONTAINER_NAMES[@]}"

command('switch (cached-volumes|delegated-volumes|mutagen|docker-sync)'):
command('switch (cached-volumes|delegated-volumes|mutagen)'):
env:
SYNC: = input.command(2)
CONTAINER_NAMES: = get_mutagen_volume_containers()
Expand All @@ -75,26 +75,16 @@ command('switch (cached-volumes|delegated-volumes|mutagen|docker-sync)'):
if [[ "$SYNC" = "delegated-volumes" ]]; then
ws set delegated-volumes yes
ws set mutagen no
ws set docker-sync no
elif [[ "$SYNC" = "mutagen" ]]; then
ws set delegated-volumes no
ws set mutagen yes
ws set docker-sync no
elif [[ "$SYNC" = "docker-sync" ]]; then
ws set delegated-volumes no
ws set mutagen no
ws set docker-sync yes
else
ws set delegated-volumes no
ws set mutagen no
ws set docker-sync no
fi
run ws harness prepare
echo 'Bringing up the environment with the new setting'
if [[ "$SYNC" = "mutagen" ]]; then
if command -v docker-sync >/dev/null 2>&1 && [ -f docker-sync.yml ]; then
passthru ws docker-sync clean
fi
passthru ws mutagen start
else
passthru ws mutagen stop
Expand Down
5 changes: 1 addition & 4 deletions src/_base/harness/scripts/destroy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

run docker-compose down --rmi local --volumes --remove-orphans --timeout 120

if [[ "$USE_DOCKER_SYNC" = "yes" ]] && [ -f docker-sync.yml ]; then
run ws docker-sync clean
run docker volume rm "${NAMESPACE}-sync"
elif [[ "$USE_MUTAGEN" = "yes" ]]; then
if [[ "$USE_MUTAGEN" = "yes" ]]; then
run ws mutagen stop
passthru ws mutagen rm
fi
Expand Down
4 changes: 1 addition & 3 deletions src/_base/harness/scripts/disable.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash

if [[ "$USE_DOCKER_SYNC" = "yes" ]] && [ -f docker-sync.yml ]; then
run ws docker-sync stop
elif [[ "$USE_MUTAGEN" = "yes" ]]; then
if [[ "$USE_MUTAGEN" = "yes" ]]; then
run ws mutagen pause
fi

Expand Down
84 changes: 0 additions & 84 deletions src/_base/harness/scripts/docker_sync.sh

This file was deleted.

12 changes: 3 additions & 9 deletions src/_base/harness/scripts/enable.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@ main()
passthru docker-compose exec -T -u build console app welcome
fi

if [[ "$APP_BUILD" = "dynamic" && "$USE_DOCKER_SYNC" = "yes" ]]; then
passthru ws docker-sync start
elif [[ "$APP_BUILD" = "dynamic" && "$USE_MUTAGEN" = "yes" ]]; then
if [[ "$APP_BUILD" = "dynamic" && "$USE_MUTAGEN" = "yes" ]]; then
passthru ws mutagen resume
fi
}

dynamic()
{
# we synchronise then stop docker-sync as leaving it running during the build
# will often cause it to crash.
# we synchronise then stop mutagen to avoid impacting CPU usage during the build

if [[ "$USE_DOCKER_SYNC" = "yes" ]]; then
passthru ws docker-sync start
passthru ws docker-sync stop
elif [[ "$USE_MUTAGEN" = "yes" ]]; then
if [[ "$USE_MUTAGEN" = "yes" ]]; then
passthru ws mutagen start
passthru ws mutagen pause
fi
Expand Down
1 change: 0 additions & 1 deletion src/akeneo/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ confd('harness:/'):
- { src: application/skeleton/README.md }
- { src: mutagen.yml, dst: workspace:/mutagen.yml } # docker-compose.yml render reads this file
- { src: docker-compose.yml, dst: workspace:/docker-compose.yml }
- { src: docker-sync.yml, dst: workspace:/docker-sync.yml }
- { src: harness/scripts/enable.sh }
- { src: helm/app/_twig/templates/service/varnish/configmap.yaml, dst: harness:/helm/app/templates/service/varnish/configmap.yaml }
- { src: helm/app/values.yaml }
Expand Down
1 change: 0 additions & 1 deletion src/drupal8/harness/config/confd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ confd('harness:/'):
- { src: application/skeleton/README.md }
- { src: mutagen.yml, dst: workspace:/mutagen.yml } # docker-compose.yml render reads this file
- { src: docker-compose.yml, dst: workspace:/docker-compose.yml }
- { src: docker-sync.yml, dst: workspace:/docker-sync.yml }
- { src: harness/scripts/enable.sh }
- { src: helm/app/_twig/templates/service/varnish/configmap.yaml, dst: harness:/helm/app/templates/service/varnish/configmap.yaml }
- { src: helm/app/values.yaml }
Expand Down
Loading