Skip to content
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
11 changes: 4 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
with:
go-version: "1.24"

- name: Download modules
run: go mod download

- name: Build
run: make build

Expand All @@ -35,7 +32,7 @@ jobs:
go-version: "1.24"

- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

- name: Lint
run: make lint
uses: golangci/golangci-lint-action@v7
with:
version: latest
args: ./...
69 changes: 54 additions & 15 deletions .github/workflows/dev-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [dev-testing]

env:
REGISTRY: ghcr.io
GHCR_IMAGE: ghcr.io/will-luck/docker-sentinel

jobs:
test:
Expand All @@ -25,33 +25,72 @@ jobs:

build-image:
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: type=raw,value=dev
- uses: docker/build-push-action@v6
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: ${{ matrix.platform }}
build-args: |
VERSION=dev-${{ github.sha }}
COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-from: type=gha,scope=dev-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=dev-${{ matrix.platform }}
outputs: type=image,"name=${{ env.GHCR_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.runner }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge-manifests:
needs: [build-image]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Create manifest list
working-directory: /tmp/digests
run: |
docker buildx imagetools create -t "${{ env.GHCR_IMAGE }}:dev" \
$(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)
112 changes: 90 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
tags: ['v*']

env:
REGISTRY: ghcr.io
GHCR_IMAGE: ghcr.io/will-luck/docker-sentinel
DOCKERHUB_IMAGE: willluck/docker-sentinel

jobs:
test:
Expand All @@ -22,16 +23,83 @@ jobs:
run: make frontend
- name: Run tests
run: go test -count=1 ./...
- name: Upload frontend bundle
uses: actions/upload-artifact@v4
with:
name: frontend-bundle
path: |
internal/web/static/app.js
internal/web/static/app.js.map
internal/web/static/style.css
internal/web/static/style.css.map
retention-days: 1

build-image:
needs: [test]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v6
with:
context: .
platforms: ${{ matrix.platform }}
build-args: |
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
cache-from: type=gha,scope=build-${{ matrix.platform }}
cache-to: type=gha,mode=max,scope=build-${{ matrix.platform }}
outputs: type=image,"name=${{ env.GHCR_IMAGE }},${{ env.DOCKERHUB_IMAGE }}",push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
env:
DIGEST: ${{ steps.build.outputs.digest }}
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.runner }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge-manifests:
needs: [build-image]
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
Expand All @@ -46,25 +114,23 @@ jobs:
id: meta
with:
images: |
ghcr.io/${{ github.repository }}
willluck/docker-sentinel
${{ env.GHCR_IMAGE }}
${{ env.DOCKERHUB_IMAGE }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
VERSION=${{ github.ref_name }}
COMMIT=${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Create manifest list (GHCR)
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.GHCR_IMAGE }}@sha256:%s ' *)
- name: Create manifest list (Docker Hub)
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map(select(startswith("willluck/")) | "-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKERHUB_IMAGE }}@sha256:%s ' *)

release:
needs: [test]
Expand All @@ -76,10 +142,11 @@ jobs:
- uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Install esbuild
run: go install github.com/evanw/esbuild/cmd/esbuild@latest
- name: Bundle frontend
run: make frontend
- name: Download frontend bundle
uses: actions/download-artifact@v4
with:
name: frontend-bundle
path: internal/web/static/
- name: Build binaries
run: |
mkdir -p dist
Expand All @@ -95,6 +162,7 @@ jobs:
CGO_ENABLED=0 GOOS="$OS" GOARCH="${ARCH_RAW%%/*}" go build -ldflags="-s -w -X main.version=${{ github.ref_name }} -X main.commit=${{ github.sha }}" -o "dist/docker-sentinel-${OS}-${ARCH}" ./cmd/sentinel
done
- name: Create release
run: gh release create ${{ github.ref_name }} dist/* --generate-notes
run: gh release create "$TAG" dist/* --generate-notes
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.ref_name }}
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ COPY . .
ARG VERSION=dev
ARG COMMIT=unknown
RUN make frontend
RUN CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT}" -o /sentinel ./cmd/sentinel
RUN --mount=type=cache,target=/root/.cache/go-build \
CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION} -X main.commit=${COMMIT}" -o /sentinel ./cmd/sentinel

FROM alpine:3.21

Expand Down
Loading