Skip to content

Commit

Permalink
Update platform and rename/tidy github action files
Browse files Browse the repository at this point in the history
  • Loading branch information
apricot13 committed Jun 11, 2024
1 parent b3ed9e4 commit f64a865
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 48 deletions.
3 changes: 2 additions & 1 deletion .docker/services/mongo/mongo.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
version: "3.7"
services:
mongo:
image: mongo:6
image: mongo:latest
platform: linux/arm64
ports:
- 27018:27017
volumes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3.7"
services:
outpost-api-service:
image: ghcr.io/wearefuturegov/outpost-api-service:latest
container_name: outpost-api-service
platform: linux/arm64
environment:
NODE_ENV: development
FORCE_SSL: false
Expand Down
32 changes: 0 additions & 32 deletions .github/workflows/outpost-image.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This action pre-builds the dev-base image and pushes it to the GitHub Container Registry (GHCR)

name: Deploy dev-base image to github container registry
name: Publish outpost dev-base image to github container registry

on:
push:
Expand All @@ -12,12 +12,21 @@ on:
- cron: "0 8 1 * *"

jobs:
push-dev-base-image:
publish-dev-base:
runs-on: ubuntu-latest
strategy:
matrix:
platforms: ["linux/amd64", "linux/arm64", "linux/arm64/v8"]
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@main

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/publish-outpost-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This action pre-builds the dev-base image and pushes it to the GitHub Container Registry (GHCR)

name: Publish outpost image to github container registry

on:
push:
branches: [develop, staging, production]

jobs:
push-outpost-image:
runs-on: ubuntu-latest
strategy:
matrix:
platforms: ["linux/amd64", "linux/arm64", "linux/arm64/v8"]
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@main

- name: "Login to GitHub Container Registry"
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}

- name: Set Docker Image Tag
id: vars
run: |
BRANCH_NAME=${GITHUB_REF#refs/heads/}
if [[ "$BRANCH_NAME" == "develop" ]]; then
echo "tag=development" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "staging" ]]; then
echo "tag=staging" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "production" ]]; then
echo "tag=latest" >> $GITHUB_ENV
else
echo "tag=default" >> $GITHUB_ENV
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push outpost docker image
uses: docker/build-push-action@v5
with:
context: .
tags: ghcr.io/wearefuturegov/outpost:${{ env.tag }}
file: Dockerfile.production
platforms: ${{ matrix.platforms }}
push: true
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Outpost image
labels: org.opencontainers.image.source=https://github.com/wearefuturegov/outpost
44 changes: 44 additions & 0 deletions .github/workflows/test-docker-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This action tests to make sure that the docker image can be built successfully on the specified platforms

name: Test outpost image docker build

on: push

jobs:
test-docker-build:
runs-on: ubuntu-latest
strategy:
matrix:
platforms: ["linux/amd64", "linux/arm64", "linux/arm64/v8"]
steps:
- name: "Checkout GitHub Action"
uses: actions/checkout@main

- name: Set Docker Image Tag
id: vars
run: |
BRANCH_NAME=${GITHUB_HEAD_REF#refs/heads/}
if [[ "$BRANCH_NAME" == "develop" ]]; then
echo "tag=development" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "staging" ]]; then
echo "tag=staging" >> $GITHUB_ENV
elif [[ "$BRANCH_NAME" == "production" ]]; then
echo "tag=latest" >> $GITHUB_ENV
else
echo "tag=default" >> $GITHUB_ENV
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: .
tags: outpost:${{ env.tag }}
file: Dockerfile.production
platforms: ${{ matrix.platforms }}
push: false
2 changes: 1 addition & 1 deletion .github/workflows/test-in-herokuish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Run tests in herokuish
# on: [push]

jobs:
build:
test-in-herokuish:
runs-on: ubuntu-latest

services:
Expand Down
22 changes: 11 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ list: help
# we could also use make start cmd="up" but the docker image is set to use start as the entrypoint and up as the cmd by default
up: ## Start the application as if it were in production
docker run -d --rm --name outpost_production \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-production-network \
-e PORT=3000 \
-p 3002:3000/tcp \
Expand All @@ -48,7 +48,7 @@ pull: ## fetch the herokuish image

build: pull ## build the production image
docker build \
--platform linux/amd64 \
--platform linux/arm64 \
--build-arg NODE_OPTIONS=--openssl-legacy-provider \
--build-arg NODE_ENV=production \
--build-arg RAILS_ENV=production \
Expand All @@ -59,7 +59,7 @@ exec: ## execute a command on the production image eg make exec cmd="bin/rails c
@if [ -z "$(cmd)" ]; then echo "cmd is required"; exit 1; fi
docker run -it --rm \
--name outpost_production_release \
--platform linux/amd64 \
--platform linux/arm64 \
--entrypoint /exec \
--network outpost-production-network \
-e NODE_ENV=production \
Expand All @@ -72,7 +72,7 @@ start: ## execute a command from the Procfile eg make start cmd=release
@if [ -z "$(cmd)" ]; then echo "cmd is required"; exit 1; fi
docker run -it --rm \
--name outpost_production_release \
--platform linux/amd64 \
--platform linux/arm64 \
--entrypoint /start \
--network outpost-production-network \
-e NODE_ENV=production \
Expand All @@ -89,7 +89,7 @@ production: ## create a production environment
docker volume create outpost-production-postgres-volume

docker run -d --name outpost-production-mongo \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-production-network \
-p 27020:27017 \
-v outpost-production-mongo-volume:/data/db \
Expand All @@ -100,7 +100,7 @@ production: ## create a production environment
mongo:6

docker run -d --name outpost-production-postgres \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-production-network \
-p 5435:5432 \
-v outpost-production-postgres-volume:/var/lib/postgresql/data \
Expand Down Expand Up @@ -139,7 +139,7 @@ tests: ## run tests as if it were in production but on local code
docker volume create outpost-test-postgres-volume

docker run -d --name outpost-test-mongo \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-test-network \
-p 27019:27017 \
-v outpost-test-mongo-volume:/data/db \
Expand All @@ -150,7 +150,7 @@ tests: ## run tests as if it were in production but on local code
mongo:6

docker run -d --name outpost-test-postgres \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-test-network \
-p 5434:5432 \
-v outpost-test-postgres-volume:/var/lib/postgresql/data \
Expand All @@ -163,7 +163,7 @@ tests: ## run tests as if it were in production but on local code

tests-built: ## Run the tests from your local code on the prebuilt image
docker run --rm --name outpost_test \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-test-network \
-e "DATABASE_URL=postgresql://outpost:password@outpost-test-postgres:5432/outpost?" \
-e "DB_URI=mongodb://outpost-test-mongo:27017/outpost_api_test" \
Expand All @@ -175,7 +175,7 @@ tests-built: ## Run the tests from your local code on the prebuilt image

tests-local: ## Run the tests from your local code
docker run --rm --name outpost_test \
--platform linux/amd64 \
--platform linux/arm64 \
--network outpost-test-network \
-e "DATABASE_URL=postgresql://outpost:password@outpost-test-postgres:5432/outpost?" \
-e "DB_URI=mongodb://outpost-test-mongo:27017/outpost_api_test" \
Expand All @@ -187,7 +187,7 @@ tests-local: ## Run the tests from your local code

tests-build: ## build the test image
docker build \
--platform linux/amd64 \
--platform linux/arm64 \
--build-arg NODE_OPTIONS=--openssl-legacy-provider \
--build-arg NODE_ENV=development \
--build-arg RAILS_ENV=test \
Expand Down

0 comments on commit f64a865

Please sign in to comment.