Skip to content

Commit

Permalink
Ensure that Docker Compose within projects work as expected
Browse files Browse the repository at this point in the history
When setting up projects configure Dapple-specific COMPOSE_PROJECT_NAME 
values in the project .env files. This will ensure that containers will
not conflict with default project checkouts using defaults and that 
subsequent docker commands will work on the Dapple-initiated containers.

Update our test to ensure that it works as expected.
  • Loading branch information
kasperg committed Dec 5, 2023
1 parent c280d05 commit e8c342e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Initialize environment
run: "task init ${{ env.TASK_OUTPUT }}"
- name: Ensure CMS is initialized properly
# If we can list running containers in the CMS directory after
# initializing then docker commands within the subdirectory will work
# with the Dapple-initiated containers as expected.
working-directory: cms
run: "docker compose ps --format json | jq -e 'select(.State == \"running\") | length > 0'"
- name: Link Design system to React components
run: "task react:link ${{ env.TASK_OUTPUT }}"
- name: Link Design system and React components to CMS
Expand Down
13 changes: 8 additions & 5 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ version: '3'

output: prefixed

env:
# Set project name to avoid conflicts with single checkouts.
COMPOSE_PROJECT_NAME: dapple
vars:
COMPOSE_PREFIX: dapple
CMS_COMPOSE_PROJECT_NAME: "{{.COMPOSE_PREFIX}}-cms"
REACT_COMPOSE_PROJECT_NAME: "{{.COMPOSE_PREFIX}}-react"

tasks:
init:
Expand Down Expand Up @@ -77,8 +78,9 @@ tasks:
react:clone:
cmds:
- git clone https://github.com/danskernesdigitalebibliotek/dpl-react react
# Set project name to avoid conflicts with single checkouts.
- cp react/.env.example react/.env
- echo "COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}-react" >> react/.env
- echo "COMPOSE_PROJECT_NAME={{.REACT_COMPOSE_PROJECT_NAME}}" >> react/.env

react:link:
dir: react
Expand Down Expand Up @@ -117,7 +119,8 @@ tasks:
cms:clone:
cmds:
- git clone https://github.com/danskernesdigitalebibliotek/dpl-cms cms
- sed "s|COMPOSE_PROJECT_NAME=dpl-cms|COMPOSE_PROJECT_NAME=${COMPOSE_PROJECT_NAME}-cms|g" <cms/.env.example >cms/.env
# Set project name to avoid conflicts with single checkouts.
- sed "s|COMPOSE_PROJECT_NAME=dpl-cms|COMPOSE_PROJECT_NAME={{.CMS_COMPOSE_PROJECT_NAME}}|g" <cms/.env.example >cms/.env

cms:link:
dir: cms
Expand Down

0 comments on commit e8c342e

Please sign in to comment.