Skip to content

Commit

Permalink
build(github-action): Docker builds (#20)
Browse files Browse the repository at this point in the history
DockerHub, GHCR, Quay
  • Loading branch information
JosephKav committed May 3, 2022
1 parent 70d049d commit 6cd458c
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: Build
name: Binary Build

on:
release:
types: [ published ]

jobs:
build:
name: Build
build-binary:
name: Binary Build
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down
95 changes: 95 additions & 0 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Docker Build
on:
push:
branches:
- master
release:
types: [ published ]

jobs:
build-docker:
name: Docker Build
runs-on: ubuntu-latest

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

- name: Set outputs
id: vars
run: |
echo "sha_short=$(git rev-parse --short HEAD)" >> ${GITHUB_ENV}
echo "repository=${repository,,}" >> ${GITHUB_ENV}
echo "repository_owner=${repository_owner,,}" >> ${GITHUB_ENV}
env:
repository: '${{ github.repository }}'
repository_owner: '${{ github.repository_owner }}'

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

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1
with:
install: true

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ env.repository_owner }}
password: ${{ secrets.GH_TOKEN }}

- name: Login to Quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push (release)
id: docker_build_release
if: github.event_name == 'release'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
hymenaios/hymenaios:${{ github.event.release.tag_name }}
hymenaios/hymenaios:latest
ghcr.io/${{ env.repository }}:${{ github.event.release.tag_name }}
ghcr.io/${{ env.repository }}:latest
quay.io/hymenaios/hymenaios:${{ github.event.release.tag_name }}
quay.io/hymenaios/hymenaios:latest
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm,linux/arm64
build-args: |
BUILD_VERSION=${{ github.event.release.tag_name }}
- name: Build and push (master)
id: docker_build_master
if: github.event_name == 'push'
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: |
hymenaios/hymenaios:master
ghcr.io/${{ env.repository }}:master
quay.io/hymenaios/hymenaios:master
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
platforms: linux/amd64,linux/arm,linux/arm64
build-args: |
BUILD_VERSION=${{ env.sha_short }}
34 changes: 29 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
########
# BASE #
########
ARG GO_VERSION="1.18.1"
ARG DEBIAN_VERSION="bullseye"
FROM golang:${GO_VERSION}-${DEBIAN_VERSION}
# Install node for Makefille.common's:
# $(shell node -p "require('./web/ui/react-app/package.json').$(1)")
RUN \
apt-get update && \
apt-get install nodejs -y

COPY . /build/
WORKDIR /build/

ARG BUILD_VERSION="development"
RUN make BUILD_VERSION=${BUILD_VERSION} go-build
RUN chmod 755 /build/hymenaios


#############
# HYMENAIOS #
#############
ARG DEBIAN_VERSION="bullseye"
FROM debian:${DEBIAN_VERSION}-slim
LABEL maintainer="The Hymenaios Authors <developers@hymenaios.io>"
RUN \
apt-get update && \
apt-get install ca-certificates -y && \
apt-get clean

ARG ARCH="amd64"
ARG OS="linux"
COPY config.yml.example /etc/hymenaios/config.yml
COPY .build/${OS}/${ARCH}/hymenaios /bin/hymenaios
COPY LICENSE /LICENSE
COPY --from=0 /build/hymenaios /bin/hymenaios
COPY --from=0 /build/config.yml.example /etc/hymenaios/config.yml
COPY --from=0 /build/LICENSE /LICENSE

WORKDIR /hymenaios
RUN chown -R nobody:nogroup /etc/hymenaios /hymenaios
Expand Down
3 changes: 2 additions & 1 deletion config.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ service:
hymenaios-io/hymenaios:
type: github
url: hymenaios-io/hymenaios
regex_version: '^[0-9.]+[0-9]$'
web_url: https://github.com/hymenaios-io/Hymenaios/blob/master/CHANGELOG.md
icon: https://github.com/hymenaios-io/Hymenaios/raw/master/web/ui/static/favicon.svg

0 comments on commit 6cd458c

Please sign in to comment.