Skip to content

Commit

Permalink
#67 Detect if containers exist upon enable with flag-built
Browse files Browse the repository at this point in the history
  • Loading branch information
kierenevans committed Jan 6, 2021
1 parent 68a3021 commit 096d15f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 97 deletions.
6 changes: 3 additions & 3 deletions src/_base/harness/config/events.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ after('harness.refresh'):
exec: |
#!bash(workspace:/)|@
run docker-compose stop
passthru "docker-compose config --services | grep -v php-fpm | xargs docker-compose pull"
passthru "docker-compose config --services | grep -v cron | grep -v job-queue-consumer | grep -v jenkins-runner | xargs docker-compose build --pull"
passthru "docker-compose config --services | grep -v cron | grep -v job-queue-consumer | grep -v jenkins-runner | xargs docker-compose up -d"
ws external-images pull
passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | grep -v job-queue-consumer | xargs docker-compose build"
passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | grep -v job-queue-consumer | xargs docker-compose up -d"
run docker-compose up -d --build
8 changes: 6 additions & 2 deletions src/_base/harness/config/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
command('app build'):
env:
HAS_CRON: "= @('services.cron.enabled') ? 'true' : 'false'"
HAS_WEBAPP: "= @('services.webapp.enabled') ? 'true' : 'false'"
HAS_JENKINS_RUNNER: "= @('services.jenkins-runner.enabled') ? 'true' : 'false'"
HAS_JOB_QUEUE_CONSUMER: "= @('services.job-queue-consumer.enabled') ? 'true' : 'false'"
HAS_WEBAPP: "= @('services.webapp.enabled') ? 'true' : 'false'"
exec: |
#!bash(workspace:/)|@
ws external-images pull
# dependency ordered build
passthru docker-compose build console
if [[ "${HAS_WEBAPP}" == "true" ]] || [[ "${HAS_CRON}" == "true" ]]; then
if [[ "${HAS_WEBAPP}" == "true" ]] || [[ "${HAS_CRON}" == "true" ]] || [ "${HAS_JOB_QUEUE_CONSUMER}" == "true" ]; then
passthru docker-compose build php-fpm
fi
if [[ "${HAS_WEBAPP}" == "true" ]]; then
Expand All @@ -22,6 +23,9 @@ command('app build'):
if [[ "${HAS_JENKINS_RUNNER}" == "true" ]]; then
passthru docker-compose build jenkins-runner
fi
if [[ "${HAS_JOB_QUEUE_CONSUMER}" == "true" ]]; then
passthru docker-compose build job-queue-consumer
fi
command('app build <service>'):
env:
Expand Down
26 changes: 21 additions & 5 deletions src/_base/harness/scripts/enable.sh.twig
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

main()
{
passthru ws networks external
if [ ! -f .my127ws/.flag-built ]; then
local IS_BUILT=no
local HAS_FLAG=no

if [ -f .my127ws/.flag-built ]; then
HAS_FLAG=yes
IS_BUILT=yes
# If no lines for `docker-compose ps`, the containers no longer exist so we need to rebuild them
if [ "$(docker-compose ps -q | wc -l)" = "0" ]; then
IS_BUILT=no
fi
fi

passthru docker-compose down
passthru ws networks external
if [ "$IS_BUILT" = "no" ]; then
if [ "$HAS_FLAG" = "no" ]; then
passthru docker-compose down
fi

if [[ "$HAS_ASSETS" = "yes" ]]; then
ws assets download
Expand Down Expand Up @@ -41,19 +54,22 @@ dynamic()

ws external-images pull

passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | xargs docker-compose build"
passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | grep -v job-queue-consumer | xargs docker-compose build"

{% if @('services.cron.enabled') %}
passthru docker-compose build cron
{% endif %}
{% if @('services.jenkins-runner.enabled') %}
passthru docker-compose build jenkins-runner
{% endif %}
{% if @('services.job-queue-consumer.enabled') %}
passthru docker-compose build job-queue-consumer
{% endif %}

# Bring up console to fix file permissions
passthru docker-compose up -d console

# Bring up all services apart from cron and jenkins-runner
# Bring up all services apart from cron, jenkins-runner and job-queue-consumer
passthru "docker-compose config --services | grep -v cron | grep -v jenkins-runner | xargs docker-compose up -d"

passthru docker-compose exec -T -u build console app build
Expand Down
8 changes: 0 additions & 8 deletions src/akeneo/harness/config/q-akeneo-pipeline.yml

This file was deleted.

79 changes: 0 additions & 79 deletions src/akeneo/harness/scripts/enable.sh.twig

This file was deleted.

0 comments on commit 096d15f

Please sign in to comment.