Skip to content
Open
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
12 changes: 12 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.dll
*.so
*.dylib
vouch

# Test binary, build with `go test -c`
*.test
Expand All @@ -20,4 +21,15 @@ coverage.html
# Local TODO
TODO.md

# VCS and editor metadata
.git
.gitignore
.github
.idea
.vscode
.DS_Store

# Logs
*.log

Dockerfile
35 changes: 32 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,21 +1,50 @@
FROM golang:1.25-bookworm AS builder
FROM --platform=$BUILDPLATFORM golang:1.25-bookworm AS builder

WORKDIR /app

ARG BUILDARCH
RUN <<-EOF
set -e
packages=""
case "$BUILDARCH" in
amd64) packages="$packages gcc-aarch64-linux-gnu g++-aarch64-linux-gnu" ;;
arm64) packages="$packages gcc-x86-64-linux-gnu g++-x86-64-linux-gnu" ;;
*) echo "unsupported build architecture: $BUILDARCH" >&2; exit 1 ;;
esac
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y $packages
apt-get clean
rm -rf /var/lib/apt/lists/*
EOF

COPY go.mod go.sum ./

RUN go mod download

COPY . .

RUN go build
ARG TARGETOS
ARG TARGETARCH
RUN <<-EOF
set -e
if [ "$BUILDARCH" = "$TARGETARCH" ]; then
export CC=gcc CXX=g++
else
case "$TARGETARCH" in
amd64) export CC=x86_64-linux-gnu-gcc CXX=x86_64-linux-gnu-g++ ;;
arm64) export CC=aarch64-linux-gnu-gcc CXX=aarch64-linux-gnu-g++ ;;
*) echo "unsupported target architecture: $TARGETARCH" >&2; exit 1 ;;
esac
fi
CGO_ENABLED=1 GOOS=$TARGETOS GOARCH=$TARGETARCH CC=$CC CXX=$CXX go build -o /app/vouch .
EOF

FROM debian:bookworm-slim

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt install -y ca-certificates && apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR /app

COPY --from=builder /app/vouch /app
COPY --from=builder /app/vouch /app/vouch

ENTRYPOINT ["/app/vouch"]