Skip to content

Commit

Permalink
Add build and run scripts, use ghcr tags
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Aug 9, 2024
1 parent 07effeb commit ecd5317
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 24 deletions.
6 changes: 3 additions & 3 deletions db/scripts/build
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env bash
set -e
HERE=$(dirname $0)
. $HERE/common
. $HERE/../../docker/common

PACKAGE_ROOT=$(realpath $HERE/..)

docker build \
-t "$TAG_SHA" \
-t "$TAG_BRANCH" \
-t "$DB_TAG_SHA" \
-t "$DB_TAG_BRANCH" \
$PACKAGE_ROOT
19 changes: 0 additions & 19 deletions db/scripts/common

This file was deleted.

4 changes: 2 additions & 2 deletions db/scripts/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
set -e

HERE=$(dirname $0)
. $HERE/common
. $HERE/../../docker/common

docker run --rm -d \
--network=bridge \
--name daedalus-web-app-db \
-p 5432:5432 \
"$TAG_BRANCH"
"$DB_TAG_BRANCH"
9 changes: 9 additions & 0 deletions docker/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
HERE=$(dirname $0)
. $HERE/common

docker build \
--tag $APP_TAG_SHA \
-f docker/Dockerfile \
.
26 changes: 26 additions & 0 deletions docker/common
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -ex

if [[ -v "GITHUB_SHA" ]]; then
GIT_ID=${GITHUB_SHA:0:7}
else
GIT_ID=$(git rev-parse --short=7 HEAD)
fi

if [[ -v "BRANCH_NAME" ]]; then
GIT_BRANCH=${BRANCH_NAME}
else
GIT_BRANCH=$(git symbolic-ref --short HEAD)
fi

REGISTRY=ghcr.io
ORG=jameel-institute
DB_IMAGE_NAME=daedalus-web-app-db
DB_TAG="${REGISTRY}/${ORG}/${DB_IMAGE_NAME}"
DB_TAG_SHA="${DB_TAG}:${GIT_ID}"
DB_TAG_BRANCH="${DB_TAG}:${GIT_BRANCH}"

APP_IMAGE_NAME=daedalus-web-app
APP_TAG="${REGISTRY}/${ORG}/${APP_IMAGE_NAME}"
APP_TAG_SHA="${APP_TAG}:${GIT_ID}"
APP_TAG_BRANCH="${APP_TAG}:${GIT_BRANCH}"
12 changes: 12 additions & 0 deletions docker/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -e
HERE=$(dirname $0)
. $HERE/common
# run web app image, assuming dependencies are already running
docker run --rm -d \
--network bridge \
--name daedalus-web-app \
-p 3000:3000 \
"$APP_TAG_SHA"

# env vars

0 comments on commit ecd5317

Please sign in to comment.