Skip to content

Commit 1dfa36f

Browse files
authored
Merge pull request #7 from nginx-proxy/docker-images
ci: build and publish Forego Docker images
2 parents 3aff773 + 55d3b27 commit 1dfa36f

File tree

6 files changed

+145
-0
lines changed

6 files changed

+145
-0
lines changed

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ updates:
88
commit-message:
99
prefix: "build"
1010

11+
# Maintain dependencies for Docker
12+
- package-ecosystem: "docker"
13+
directory: "/"
14+
schedule:
15+
interval: "daily"
16+
commit-message:
17+
prefix: "build"
18+
1119
# Maintain GitHub Actions
1220
- package-ecosystem: "github-actions"
1321
directory: "/"

.github/workflows/build-publish.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build and publish Docker images
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
tags:
9+
- "v*.*.*"
10+
11+
jobs:
12+
multiarch-build:
13+
name: Build and publish image
14+
strategy:
15+
matrix:
16+
base: [alpine, debian]
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v3
22+
with:
23+
fetch-depth: 0
24+
25+
- name: Retrieve version
26+
id: forego_version
27+
run: echo "VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"
28+
29+
- name: Get Docker image tags
30+
id: docker_meta
31+
uses: docker/metadata-action@v4
32+
with:
33+
images: |
34+
ghcr.io/nginx-proxy/forego
35+
nginxproxy/forego
36+
tags: |
37+
type=semver,pattern={{version}}
38+
type=semver,pattern={{major}}.{{minor}}
39+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'alpine' }}
40+
type=raw,value=debian,enable=${{ github.ref == 'refs/heads/main' && matrix.base == 'debian' }}
41+
labels: |
42+
org.opencontainers.image.authors=Nicolas Duchon <[email protected]> (@buchdag)
43+
org.opencontainers.image.version=${{ steps.forego_version.outputs.VERSION }}
44+
45+
- name: Set up QEMU
46+
uses: docker/setup-qemu-action@v2
47+
48+
- name: Set up Docker Buildx
49+
uses: docker/setup-buildx-action@v2
50+
51+
- name: Login to DockerHub
52+
uses: docker/login-action@v2
53+
with:
54+
username: ${{ secrets.DOCKERHUB_USERNAME }}
55+
password: ${{ secrets.DOCKERHUB_TOKEN }}
56+
57+
- name: Log in to GitHub Container Registry
58+
uses: docker/login-action@v2
59+
with:
60+
registry: ghcr.io
61+
username: ${{ github.actor }}
62+
password: ${{ secrets.GITHUB_TOKEN }}
63+
64+
- name: Build and push the image
65+
id: docker_build
66+
uses: docker/build-push-action@v4
67+
with:
68+
context: .
69+
platforms: linux/amd64,linux/arm64,linux/arm/v7
70+
file: Dockerfile.${{ matrix.base }}
71+
push: true
72+
tags: ${{ steps.docker_meta.outputs.tags }}
73+
labels: ${{ steps.docker_meta.outputs.labels }}
74+
75+
- name: Image digest
76+
run: echo ${{ steps.docker_build.outputs.digest }}

Dockerfile.alpine

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Build forego
2+
FROM golang:1.20.3-alpine as go-builder
3+
4+
RUN apk add --no-cache musl-dev
5+
6+
WORKDIR /build
7+
8+
# Install the dependencies
9+
COPY . .
10+
RUN go mod download
11+
12+
RUN CGO_ENABLED=0 go build -o forego . \
13+
&& go clean -cache
14+
15+
FROM alpine:3.17.3
16+
17+
RUN apk add --no-cache bash
18+
19+
# Install Forego
20+
COPY --from=go-builder /build/forego /usr/local/bin/forego
21+
22+
COPY /app /app
23+
WORKDIR /app
24+
25+
CMD ["forego", "start", "-r"]

Dockerfile.debian

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Build forego
2+
FROM golang:1.20.3 as go-builder
3+
4+
WORKDIR /build
5+
6+
# Install the dependencies
7+
COPY . .
8+
RUN go mod download
9+
10+
RUN CGO_ENABLED=0 GOOS=linux go build -o forego . \
11+
&& go clean -cache
12+
13+
FROM debian:11.7-slim
14+
15+
# Install Forego
16+
COPY --from=go-builder /build/forego /usr/local/bin/forego
17+
18+
COPY /app /app
19+
WORKDIR /app
20+
21+
CMD ["forego", "start", "-r"]

app/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
demo: sh /app/demo.sh

app/demo.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/sh
2+
3+
NAME="$1"
4+
5+
sigterm() {
6+
echo "$NAME: got sigterm"
7+
}
8+
9+
trap sigterm TERM
10+
11+
while true; do
12+
echo "$NAME: ping $$"
13+
sleep 60
14+
done

0 commit comments

Comments
 (0)