Skip to content

Commit

Permalink
Merge pull request #85 from bacpop/poppunk-version-dev
Browse files Browse the repository at this point in the history
Use Github container registery
  • Loading branch information
absternator authored Dec 6, 2024
2 parents a50f9bb + f13b6ee commit 97b5726
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 68 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: build and push docker images
on:
push:
branches:
- main
pull_request:
branches:
- "*"
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to GHCR (GitHub Packages)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Server image
run: app/server/docker/build
- name: Build Proxy image
run: proxy/docker/build
- name: Docker smoke test
run: scripts/docker_smoke_test
- name: Push Server image branch ${{ env.BRANCH_NAME }}
run: app/server/docker/push
- name: Push Proxy image branch ${{ env.BRANCH_NAME }}
run: proxy/docker/push
7 changes: 7 additions & 0 deletions .github/workflows/jestCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Login to GHCR (GitHub Packages)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand All @@ -63,6 +69,7 @@ jobs:
- name: run all components
working-directory: .
run: ./scripts/run_test server-only

- name: Run unit and integration tests
run: npm run test
- name: stop all components
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/playwrightCI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ jobs:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Login to GHCR (GitHub Packages)
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Bring down the app with
Docker images are built on CI using `./proxy/docker/build`, `./app/server/docker/build`. If you want
to generate them from changed local sources you can run those same scripts locally to build images.

To target a branch of `beebop_py`, set `API_BRANCH` in `scripts/common`.
To target a branch of `beebop_py`, set `API_IMAGE` in `scripts/common`.

When running locally in docker, the backend is serving from `beebop_beebop-server_1`, and the front end from the proxy
container `beebop_proxy_1`.
Expand Down
25 changes: 9 additions & 16 deletions app/server/docker/common
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
#!/usr/bin/env bash
set -e

REGISTRY=ghcr.io
PACKAGE_ROOT=$(realpath $HERE/..)
PACKAGE_NAME=beebop-server
PACKAGE_ORG=mrcide
PACKAGE_ORG=bacpop

# Buildkite doesn't check out a full history from the remote (just the
# single commit) so you end up with a detached head and git rev-parse
# doesn't work
if [ "$BUILDKITE" = "true" ]; then
GIT_SHA=${BUILDKITE_COMMIT:0:7}
GIT_SHA=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD)
if [[ -v "BRANCH_NAME" ]]; then
GIT_BRANCH=${BRANCH_NAME}
else
GIT_SHA=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD)
GIT_BRANCH=$(git symbolic-ref --short HEAD)
fi

if [ "$BUILDKITE" = "true" ]; then
GIT_BRANCH=$BUILDKITE_BRANCH
else
GIT_BRANCH=$(git -C "$PACKAGE_ROOT" symbolic-ref --short HEAD)
fi

TAG_SHA="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}"
TAG_BRANCH="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}"
TAG_LATEST="${PACKAGE_ORG}/${PACKAGE_NAME}:latest"
TAG_SHA="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}"
TAG_BRANCH="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}"
TAG_LATEST="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:latest"
3 changes: 0 additions & 3 deletions app/server/docker/push
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ set -e
HERE=$(dirname $0)
. $HERE/common

# In case we switch agents between steps
[ ! -z $(docker images -q $TAG_SHA) ] || docker pull $TAG_SHA

docker tag $TAG_SHA $TAG_BRANCH
docker push $TAG_BRANCH

Expand Down
20 changes: 0 additions & 20 deletions buildkite/pipeline.yml

This file was deleted.

8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: "3"
services:
proxy:
image: mrcide/beebop-proxy:${GIT_SHA}
image: ghcr.io/bacpop/beebop-proxy:${GIT_SHA}
depends_on:
- beebop-server
ports:
Expand All @@ -10,12 +10,12 @@ services:
command:
$HOST beebop-server
beebop-server:
image: mrcide/beebop-server:${GIT_SHA}
image: ghcr.io/bacpop/beebop-server:${GIT_SHA}
depends_on:
- beebop-py-api
- beebop-redis
beebop-py-api:
image: mrcide/beebop-py:${API_BRANCH}
image: ghcr.io/bacpop/beebop-py:${API_IMAGE}
depends_on:
- beebop-redis
volumes:
Expand All @@ -26,7 +26,7 @@ services:
beebop-redis:
image: redis:5.0
beebop-py-worker:
image: mrcide/beebop-py:${API_BRANCH}
image: ghcr.io/bacpop/beebop-py:${API_IMAGE}
depends_on:
- beebop-redis
command:
Expand Down
2 changes: 1 addition & 1 deletion proxy/bin/reverse-proxy
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ if [ "$#" -eq 2 ]; then
export SERVER_NAME=$2
else
echo "Usage: <hostname> <servername>"
echo "e.g. docker run ... mrcide/beebop-proxy:master localhost beebop-server"
echo "e.g. docker run ... ghcr.io/bacpop/beebop-proxy:master localhost beebop-server"
exit 1
fi

Expand Down
2 changes: 1 addition & 1 deletion proxy/docker/build
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ docker build --pull \

# We always push the SHA tagged versions, for debugging if the tests
# after this step fail
docker push $TAG_SHA
docker push $TAG_SHA
24 changes: 9 additions & 15 deletions proxy/docker/common
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
#!/usr/bin/env bash
set -e

REGISTRY=ghcr.io
PACKAGE_ROOT=$(realpath $HERE/..)
PACKAGE_NAME=beebop-proxy
PACKAGE_ORG=mrcide
PACKAGE_ORG=bacpop

# Buildkite doesn't check out a full history from the remote (just the
# single commit) so you end up with a detached head and git rev-parse
# doesn't work
if [ "$BUILDKITE" = "true" ]; then
GIT_SHA=${BUILDKITE_COMMIT:0:7}
GIT_SHA=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD)
if [[ -v "BRANCH_NAME" ]]; then
GIT_BRANCH=${BRANCH_NAME}
else
GIT_SHA=$(git -C "$PACKAGE_ROOT" rev-parse --short=7 HEAD)
GIT_BRANCH=$(git symbolic-ref --short HEAD)
fi

if [ "$BUILDKITE" = "true" ]; then
GIT_BRANCH=$BUILDKITE_BRANCH
else
GIT_BRANCH=$(git -C "$PACKAGE_ROOT" symbolic-ref --short HEAD)
fi

TAG_SHA="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}"
TAG_BRANCH="${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}"
TAG_LATEST="${PACKAGE_ORG}/${PACKAGE_NAME}:latest"
TAG_SHA="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_SHA}"
TAG_BRANCH="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:${GIT_BRANCH}"
TAG_LATEST="${REGISTRY}/${PACKAGE_ORG}/${PACKAGE_NAME}:latest"
2 changes: 0 additions & 2 deletions proxy/docker/push
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ set -e
HERE=$(dirname $0)
. $HERE/common

# In case we switch agents between steps
[ ! -z $(docker images -q $TAG_SHA) ] || docker pull $TAG_SHA

docker tag $TAG_SHA $TAG_BRANCH
docker push $TAG_BRANCH
Expand Down
2 changes: 1 addition & 1 deletion scripts/common
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
export API_BRANCH="main"
export API_IMAGE="main"
6 changes: 3 additions & 3 deletions scripts/run_dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ PORT=5000
docker volume create $VOLUME
docker run --rm -v $VOLUME:/beebop/storage \
--pull always \
mrcide/beebop-py:$API_BRANCH \
ghcr.io/bacpop/beebop-py:$API_IMAGE \
./scripts/download_databases --refs # remove --refs to download all databases
docker network create $NETWORK > /dev/null || /bin/true

Expand All @@ -23,7 +23,7 @@ docker run -d --rm --name $NAME_WORKER --network=$NETWORK \
--pull always \
--env=REDIS_HOST="$NAME_REDIS" \
-v $VOLUME:/beebop/storage \
mrcide/beebop-py:$API_BRANCH rqworker
ghcr.io/bacpop/beebop-py:$API_IMAGE rqworker

docker run -d --rm --name $NAME_API --network=$NETWORK \
--pull always \
Expand All @@ -32,4 +32,4 @@ docker run -d --rm --name $NAME_API --network=$NETWORK \
--env=DBS_LOCATION="./storage/dbs" \
-v $VOLUME:/beebop/storage \
-p $PORT:5000 \
mrcide/beebop-py:$API_BRANCH
ghcr.io/bacpop/beebop-py:$API_IMAGE
2 changes: 1 addition & 1 deletion scripts/run_docker
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ docker cp app/server/src/resources/config.json beebop-beebop-server-1:/app/src/r
docker cp proxy/ssl/dhparam.pem beebop-proxy-1:/run/proxy/
docker cp proxy/$SSL_PATH/certificate.pem beebop-proxy-1:/run/proxy/
docker cp proxy/$SSL_PATH/key.pem beebop-proxy-1:/run/proxy/
docker run --rm -v beebop_beebop-storage:/beebop/storage mrcide/beebop-py:$API_BRANCH \
docker run --rm -v beebop_beebop-storage:/beebop/storage ghcr.io/bacpop/beebop-py:$API_IMAGE \
./scripts/download_databases --refs

0 comments on commit 97b5726

Please sign in to comment.