-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Dockerfile and docker build github action
Adds support for container builds. Github action will automatically build images on master branches and on releases and push them to the github container registry.
- Loading branch information
1 parent
91e3e2d
commit c3f644d
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: docker-build | ||
|
||
on: | ||
push: | ||
branches: | ||
- "master*" | ||
release: | ||
types: [published] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
docker-build: | ||
name: Build and deploy container images | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repo | ||
uses: actions/checkout@v2 | ||
- name: Export git tag | ||
uses: tenhaus/get-release-or-tag@v2 | ||
id: tag | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
# branch event | ||
type=ref,event=branch | ||
# tag event | ||
type=ref,event=tag | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v1 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to ghcr.io | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build image | ||
uses: docker/build-push-action@v2 | ||
with: | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: TODOCHECK_VERSION=${{ steps.tag.outputs.tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM golang:1.18.5-alpine3.16 AS build | ||
ARG TODOCHECK_VERSION=custom_version | ||
|
||
ADD . /usr/src/todocheck | ||
WORKDIR /usr/src/todocheck | ||
|
||
# Build | ||
RUN go build -ldflags "-X main.version=$TODOCHECK_VERSION" | ||
|
||
FROM alpine:3.16 | ||
COPY --from=build /usr/src/todocheck/todocheck /usr/local/bin/todocheck | ||
ENTRYPOINT ["/usr/local/bin/todocheck"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters