Skip to content

Commit

Permalink
Merge pull request #11 from privacy-scaling-explorations/ci/ghcr
Browse files Browse the repository at this point in the history
Build and publish Docker image to GHCR
  • Loading branch information
baumstern authored Jun 19, 2023
2 parents d47ea71 + c16797f commit 0385166
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# MACI artifacts
data/**


# Git
.git
.gitignore
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Create and publish a Docker image

on:
push:
branches:
- 'main'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:

build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build
run: make docker-gen VERSION=${{ github.ref_name }}

- name: Push Docker image
run: docker push ghcr.io/${{ github.repository }}:${{ github.ref_name }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,10 @@ coverage/**
# Ignore config files from project root, keeping sample config files
/configs**
!/configs.**.sample


# Ignore MACI artifacts
data/zkeys/**
*.wtns

.DS_Store
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Name of the current directory
PROJECTNAME="maci-coordinator"

REPOSITORY="privacy-scaling-explorations/$(PROJECTNAME)"

# List of all Go-files to be processed
GOFILES=$(wildcard *.go)

Expand Down Expand Up @@ -119,30 +121,30 @@ run-debug:
## :
## `docker-gen`: Create a production docker image for `maci-coordinator`
docker-gen:
echo "Building docker image \`$(IMAGE):$(VERSION)\`..."
echo "Building docker image \`ghcr.io/$(REPOSITORY):$(VERSION)\`..."
docker build --rm \
--build-arg final_image=scratch \
--build-arg build_mode=production \
-t $(IMAGE):$(VERSION) . \
-t ghcr.io/$(REPOSITORY):$(VERSION) . \
-f ./docker/Dockerfile


.PHONY: docker-debug
## `docker-debug`: Create debug-friendly docker images for `maci-coordinator`
docker-debug:
echo "Building docker image \`$(IMAGE):$(VERSION)\`..."
echo "Building docker image \`ghcr.io/$(REPOSITORY):$(VERSION)\`..."
docker build --rm=false \
--build-arg final_image=golang:1.18 \
--build-arg build_mode=debug \
-t $(IMAGE)-debug:$(VERSION) . \
-t ghcr.io/$(REPOSITORY):$(VERSION) . \
-f ./docker/Dockerfile


.PHONY: clean-docker
## `clean-docker`: Delete an existing docker image
clean-docker:
echo "Removing docker $(IMAGE):$(VERSION)..."
docker rmi -f $(IMAGE):$(VERSION)
echo "Removing docker ghcr.io/$(REPOSITORY):$(VERSION)..."
docker rmi -f ghcr.io/$(REPOSITORY):$(VERSION)


## :
Expand Down
3 changes: 3 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ ENV __BUILD_MODE__=${build_mode}
ENV ${build_mode}_mode=${build_mode}
# ^^ will be `debug_mode` or `production_mode`

# Copy demo webPage
COPY "./demo" \
"./demo"

# Run the binary
CMD ["./maci-coordinator"]

0 comments on commit 0385166

Please sign in to comment.