Skip to content

Commit

Permalink
Add CI Action for container build
Browse files Browse the repository at this point in the history
This will have a container image built and pushed automatically on any
new commit to `trunk`. Containers expect a volume mounted on
`/var/lib/webhook-gateway` with a `config.toml` file added in.
  • Loading branch information
deuill committed Oct 22, 2024
1 parent c8f2d93 commit 0df6d2d
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 7 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: WebHook Gateway Container Build
on:
push:
branches:
- trunk
pull_request:
branches:
- trunk
env:
CONTAINER_NAME: ${{ github.repository_owner }}/webhook-gateway
CONTAINER_TAG: latest
jobs:
build:
runs-on: ubuntu-latest
name: Container Build
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update -y
sudo apt-get install -y podman buildah
- name: Build container image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.CONTAINER_NAME }}
tags: ${{ env.CONTAINER_TAG }}
containerfiles: Containerfile
- name: Push to container registry
id: push-to-registry
uses: redhat-actions/push-to-registry@v2
with:
registry: ${{ vars.CONTAINER_REGISTRY_URL }}
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
username: ${{ secrets.CONTAINER_REGISTRY_USERNAME }}
password: ${{ secrets.CONTAINER_REGISTRY_PASSWORD }}
- name: Print container image URL
run: echo "Image pushed to ${{ steps.push-to-registry.outputs.registry-paths }}"
8 changes: 4 additions & 4 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM docker.io/golang:1.23-bookworm AS builder

RUN GOBIN=/build/usr/bin go install go.deuill.org/webhook-gateway@latest
COPY gateway.conf /build/etc/webhook-gateway/config.conf
RUN GOBIN=/build/usr/bin go install go.deuill.org/webhook-gateway/cmd/webhook-gateway@latest

FROM docker.io/debian:bookworm-slim
RUN apt-get update -y && apt-get upgrade -y && apt-get install -y --no-install-recommends \
ca-certificates

RUN adduser --system --group --no-create-home webhook-gateway

VOLUME /var/lib/webhook-gateway

COPY --from=builder /build /
USER webhook-gateway

ENTRYPOINT ["/usr/bin/webhook-gateway", "-config", "/etc/webhook-gateway/config.conf"]
ENTRYPOINT ["/usr/bin/webhook-gateway", "-config", "/var/lib/webhook-gateway/config.toml"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ The `webhook-gateway` binary should be placed in your `$GOBIN` path.
## Configuration

Configuration is made entirely via a single TOML file, a full example of which can be found
[here](gateway.conf). In general, providing a configuration file is mandatory as options don't
(generally) have defaults set; only a number of options are required, though. The following
[here](config.example.toml). In general, providing a configuration file is mandatory as options
don't (generally) have defaults set; only a number of options are required, though. The following
sections are available:

### `http`
Expand Down
2 changes: 1 addition & 1 deletion cmd/webhook-gateway/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (

// Global configuration.
var (
configPath = flag.String("config", "gateway.conf", "Path to main configuration file, in TOML format.")
configPath = flag.String("config", "config.toml", "Path to main configuration file, in TOML format.")
logLevel = flag.String("log-level", "info", "The minimum log level to process logs under")
)

Expand Down
File renamed without changes.

0 comments on commit 0df6d2d

Please sign in to comment.