Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dockerfile and docker build action #192

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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