Skip to content

Commit

Permalink
AHWR-364: Updating docker scripts (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobCatton authored Dec 9, 2024
1 parent 40a9f02 commit 4a8a258
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 27 deletions.
31 changes: 15 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ffc-ahwr-document-generator",
"version": "0.13.27",
"version": "0.13.28",
"description": "Generate and send documents for AHWR",
"homepage": "https://github.com/DEFRA/ffc-ahwr-document-generator",
"main": "app/index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
"overrides": {
"notifications-node-client": {
"jsonwebtoken": "9.0.0",
"axios": "^1.6.4"
"axios": "^1.7.8"
},
"@azure/identity": {
"jsonwebtoken": "9.0.0"
Expand Down
18 changes: 14 additions & 4 deletions scripts/start
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,24 @@ fi
set -e
projectRoot="$(a="/$0"; a=${a%/*}; a=${a:-.}; a=${a#/}/; cd "$a/.." || return; pwd)"

# Determine which docker compose command is available
if command -v docker compose &> /dev/null; then
compose_cmd="docker compose"
elif command -v docker-compose &> /dev/null; then
compose_cmd="docker-compose"
else
echo "Neither 'docker compose' nor 'docker-compose' is installed." >&2
exit 1
fi

cd "${projectRoot}"

docker-compose down
docker-compose -f docker-compose.migrate.yaml down
$compose_cmd down
$compose_cmd -f docker-compose.migrate.yaml down
# Ensure container images are up to date
docker-compose -f docker-compose.migrate.yaml run database-up
$compose_cmd -f docker-compose.migrate.yaml run database-up

docker-compose \
$compose_cmd \
-f docker-compose.yaml \
-f docker-compose.override.yaml \
-f docker-compose.link.yaml \
Expand Down
20 changes: 15 additions & 5 deletions scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ projectRoot="$(a="/$0"; a=${a%/*}; a=${a:-.}; a=${a#/}/; cd "$a/.." || return; p

service="ffc-ahwr-document-generator"

# Determine which docker compose command is available
if command -v docker compose &> /dev/null; then
compose_cmd="docker compose"
elif command -v docker-compose &> /dev/null; then
compose_cmd="docker-compose"
else
echo "Neither 'docker compose' nor 'docker-compose' is installed." >&2
exit 1
fi

show_help() {
echo "
Usage: scripts/test [OPTION...]
Expand Down Expand Up @@ -39,11 +49,11 @@ done

compose() {
if [ "${watch}" = "true" ]; then
docker-compose -f docker-compose.yaml -f docker-compose.test.yaml -f docker-compose.test.watch.yaml -p "${service}-test" $@
$compose_cmd -f docker-compose.yaml -f docker-compose.test.yaml -f docker-compose.test.watch.yaml -p "${service}-test" $@
elif [ "${debug}" = "true" ]; then
docker-compose -f docker-compose.yaml -f docker-compose.test.yaml -f docker-compose.test.watch.yaml -f docker-compose.test.debug.yaml -p "${service}-test" $@
$compose_cmd -f docker-compose.yaml -f docker-compose.test.yaml -f docker-compose.test.watch.yaml -f docker-compose.test.debug.yaml -p "${service}-test" $@
else
docker-compose -f docker-compose.yaml -f docker-compose.test.yaml -p "${service}-test" $@
$compose_cmd -f docker-compose.yaml -f docker-compose.test.yaml -p "${service}-test" $@
fi
}

Expand All @@ -55,11 +65,11 @@ compose() {

# Guarantee clean environment
compose down -v
docker-compose -f docker-compose.migrate.yaml -p "${service}-test" down -v
$compose_cmd -f docker-compose.migrate.yaml -p "${service}-test" down -v

# Ensure container images are up to date
compose build
docker-compose -f docker-compose.migrate.yaml -p "${service}-test" run --rm database-up
$compose_cmd -f docker-compose.migrate.yaml -p "${service}-test" run --rm database-up

# Run tests
if [ "${debug}" = "true" ]; then
Expand Down

0 comments on commit 4a8a258

Please sign in to comment.