Build multi-arch release images without emulation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7c3657d015
commit
0984af25bc
6 files changed
+45
-17
No files matched your search
@@ -59,10 +59,13 @@ jobs:
|
||||
id: sha
|
||||
run: echo "short=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
# amd64 only: these builds exist for the Unraid deploy (x86_64), and a
|
||||
# single platform keeps every push fast. Releases are multi-arch.
|
||||
- name: Build and push (:main and :<sha>)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
build-args: |
|
||||
VERSION=0.0.0-dev+${{ steps.sha.outputs.short }}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
# Builds a release when a version tag (vX.Y.Z) is pushed: the image is tagged
|
||||
# :X.Y.Z, :X.Y, :X and :latest in the Gitea registry, and a Gitea release is
|
||||
# created with the matching section of CHANGELOG.md as notes. Nothing is
|
||||
# deployed; Tom's Unraid follows :main through deploy.yml.
|
||||
# Builds a release when a version tag (vX.Y.Z) is pushed: a multi-arch image
|
||||
# (linux/amd64, linux/arm64) is tagged :X.Y.Z, :X.Y, :X and :latest in the Gitea
|
||||
# registry, and a Gitea release is created with the matching section of
|
||||
# CHANGELOG.md as notes. Nothing is deployed; Tom's Unraid follows :main through
|
||||
# deploy.yml.
|
||||
#
|
||||
# A pre-release tag such as v0.2.0-rc.1 only gets its own :0.2.0-rc.1 tag and a
|
||||
# release marked as pre-release; :latest and the short tags stay on the last
|
||||
@@ -66,10 +67,14 @@ jobs:
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
|
||||
# No QEMU: the Dockerfile compiles natively on the runner and cross-publishes
|
||||
# for each architecture; the arm64 runtime stage only copies files. Setting
|
||||
# up QEMU would also register binfmt handlers on the Unraid host kernel.
|
||||
- name: Build and push the release tags
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64
|
||||
push: true
|
||||
build-args: |
|
||||
VERSION=${{ steps.version.outputs.version }}
|
||||
|
||||
@@ -28,6 +28,7 @@ First release.
|
||||
with `Flypaper__Admin__Password`.
|
||||
- Daily retention cleanup (90 days by default), `/health` endpoint, Docker image running as
|
||||
non-root with all data under `/data`.
|
||||
- Public images for `linux/amd64` and `linux/arm64` in the Gitea registry.
|
||||
|
||||
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.1.0...main
|
||||
[0.1.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.0
|
||||
+15
-4
@@ -1,4 +1,8 @@
|
||||
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
# The SDK stage runs natively on the build machine and cross-publishes for the
|
||||
# target architecture. The runtime stage only copies files and sets metadata, so a
|
||||
# multi-arch build needs no QEMU emulation at all.
|
||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:10.0 AS build
|
||||
ARG TARGETARCH
|
||||
WORKDIR /src
|
||||
|
||||
COPY Directory.Build.props Directory.Packages.props ./
|
||||
@@ -7,22 +11,29 @@ COPY src/Flypaper.GeoIp/Flypaper.GeoIp.csproj src/Flypaper.GeoIp/
|
||||
COPY src/Flypaper.Http/Flypaper.Http.csproj src/Flypaper.Http/
|
||||
COPY src/Flypaper.Storage/Flypaper.Storage.csproj src/Flypaper.Storage/
|
||||
COPY src/Flypaper.Web/Flypaper.Web.csproj src/Flypaper.Web/
|
||||
RUN dotnet restore src/Flypaper.Web/Flypaper.Web.csproj
|
||||
RUN dotnet restore src/Flypaper.Web/Flypaper.Web.csproj -a $TARGETARCH
|
||||
|
||||
COPY src/ src/
|
||||
ARG VERSION=0.0.0-dev
|
||||
RUN dotnet publish src/Flypaper.Web/Flypaper.Web.csproj -c Release -o /app --no-restore -p:Version=$VERSION
|
||||
RUN dotnet publish src/Flypaper.Web/Flypaper.Web.csproj -c Release -a $TARGETARCH -o /app --no-restore -p:Version=$VERSION \
|
||||
&& mkdir /data
|
||||
|
||||
FROM mcr.microsoft.com/dotnet/aspnet:10.0
|
||||
ARG VERSION=0.0.0-dev
|
||||
WORKDIR /app
|
||||
|
||||
RUN mkdir /data && chown $APP_UID /data
|
||||
LABEL org.opencontainers.image.title="Flypaper" \
|
||||
org.opencontainers.image.description="Self-hosted tarpit that traps and slows down scanning bots, with event logging and analysis." \
|
||||
org.opencontainers.image.source="https://gitea.anticarnist.de/Tom/Flypaper" \
|
||||
org.opencontainers.image.licenses="MIT" \
|
||||
org.opencontainers.image.version=$VERSION
|
||||
|
||||
ENV ASPNETCORE_HTTP_PORTS= \
|
||||
ConnectionStrings__Flypaper="Data Source=/data/flypaper.db" \
|
||||
Flypaper__DataProtection__KeysPath=/data/keys \
|
||||
Flypaper__GeoIp__Directory=/data/geoip
|
||||
|
||||
COPY --from=build --chown=1654:1654 /data /data
|
||||
COPY --from=build /app .
|
||||
|
||||
USER $APP_UID
|
||||
|
||||
@@ -55,25 +55,23 @@ flowchart LR
|
||||
|
||||
## Quick start
|
||||
|
||||
There is no public image yet; build it from source. No environment variable is required.
|
||||
Images for `linux/amd64` and `linux/arm64` (e.g. Raspberry Pi 4/5 with a 64-bit OS) are
|
||||
published in the author's Gitea registry; no login is needed to pull. No environment variable
|
||||
is required.
|
||||
|
||||
```bash
|
||||
git clone <repository-url> flypaper
|
||||
cd flypaper
|
||||
docker build -t flypaper .
|
||||
docker run -d --name flypaper --restart unless-stopped \
|
||||
-p 8080:8080 -p 127.0.0.1:8081:8081 \
|
||||
-v flypaper-data:/data \
|
||||
flypaper
|
||||
gitea.anticarnist.de/tom/flypaper:latest
|
||||
```
|
||||
|
||||
Or with Compose, in a `compose.yaml` next to the `Dockerfile`:
|
||||
Or with Compose:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
flypaper:
|
||||
build: .
|
||||
image: flypaper:local
|
||||
image: gitea.anticarnist.de/tom/flypaper:latest
|
||||
container_name: flypaper
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -86,6 +84,9 @@ volumes:
|
||||
flypaper-data:
|
||||
```
|
||||
|
||||
You can also build the image yourself: clone the repository and replace the `image:` line with
|
||||
`build: .`, or run `docker build -t flypaper .`.
|
||||
|
||||
- Dashboard: <http://localhost:8081>. On the first visit Flypaper asks you to set the admin
|
||||
password; afterwards you log in with it and can change it on the settings page.
|
||||
- See the trap in action:
|
||||
@@ -118,7 +119,8 @@ first log line.
|
||||
| `:X.Y`, `:X` | The newest release of that minor or major line. |
|
||||
| `:main` | Development build of every commit on `main`. May break. |
|
||||
|
||||
There is no public image yet. To build a specific release from source:
|
||||
Pull a fixed version with `docker pull gitea.anticarnist.de/tom/flypaper:0.1.0`. To build a
|
||||
specific release from source instead:
|
||||
|
||||
```bash
|
||||
git checkout v0.1.0
|
||||
|
||||
@@ -25,6 +25,12 @@ notes. Nothing is deployed.
|
||||
git push origin v0.1.0
|
||||
```
|
||||
|
||||
The registry serves the images to anyone because the `Tom` account is public; packages
|
||||
inherit the visibility of their owner, not of the repository. To show the package on the
|
||||
repository page, link it once: Gitea → Tom → Packages → `flypaper` → Settings → Link to
|
||||
repository `Flypaper` (or `POST /api/v1/packages/Tom/container/flypaper/-/link/Flypaper` with
|
||||
a token that has `write:package`).
|
||||
|
||||
If the release step fails (e.g. the built-in token may not create releases), the images are
|
||||
already pushed. Create the release by hand: Gitea → repo → Releases → New Release, pick the
|
||||
tag, title `Flypaper X.Y.Z`, paste the changelog section.
|
||||
|
||||
Reference in new issue
Block a user