Skip to content

Commit

Permalink
Add Dockerfile and docker build github action
Browse files Browse the repository at this point in the history
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
Jasper-Ben committed Sep 18, 2022
1 parent 91e3e2d commit c3f644d
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/docker-build.yaml
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 }}
12 changes: 12 additions & 0 deletions Dockerfile
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"]
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ Optionally verify the `sha256` checksum:
Place the binary in a folder, shined upon by your `$PATH`.
* For macos & linux, that's typically `/usr/local/bin/`

## Using a Container
Alternatively to installing the todocheck binary on your system you may use a prebuilt container image from the GitHub container registry, e.g.:

```bash
docker run -it -v /path/to/project:/project -e TODOCHECK_AUTH_TOKEN=your_token ghcr.io/preslavmihaylov/todocheck --basepath /project
```

For a complete list of container tags visit the [Packages section](https://github.com/preslavmihaylov/todocheck/pkgs/container/todocheck) on the GitHub project page.
For a complete list of `docker run` options visit the [Docker documentation](https://docs.docker.com/engine/reference/commandline/run/).

# Quickstart
First, you need to configure `todocheck`'s integration with your issue tracker.
This is done by creating a `.todocheck.yaml` file in the root of your project.
Expand Down

0 comments on commit c3f644d

Please sign in to comment.