Merged Patch: (#3)

- AVIF fixed
- Removed code
- Severe changes were needed

Reviewed-on: #3
Co-authored-by: riomoo <alister@kamikishi.net>
Co-committed-by: riomoo <alister@kamikishi.net>
This commit is contained in:
riomoo 2026-01-03 09:40:17 -05:00 committed by moobot
parent bab3b6c8f7
commit 6d61266e94
Signed by: moobot
GPG key ID: 1F58B1369E1C199C
7 changed files with 1081 additions and 617 deletions

View file

@ -1,32 +1,40 @@
# Build stage
FROM golang:bookworm AS builder
FROM golang:alpine AS builder
RUN apk add --no-cache \
musl-dev \
gcc \
wget \
xz \
git
# Install UPX
RUN apt-get update && apt-get install -y wget xz-utils && rm -rf /var/lib/apt/lists/*
RUN wget https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-amd64_linux.tar.xz
RUN tar -xf upx-5.0.2-amd64_linux.tar.xz && mv upx-5.0.2-amd64_linux/upx /usr/local/bin/upx && rm -r upx-5.0.2-amd64_linux upx-5.0.2-amd64_linux.tar.xz
RUN wget https://github.com/upx/upx/releases/download/v5.0.2/upx-5.0.2-amd64_linux.tar.xz && \
tar -xf upx-5.0.2-amd64_linux.tar.xz && \
mv upx-5.0.2-amd64_linux/upx /usr/local/bin/upx && \
rm -r upx-5.0.2-amd64_linux upx-5.0.2-amd64_linux.tar.xz
WORKDIR /app
COPY go.mod ./
COPY go.mod go.sum ./
RUN go mod download
COPY . .
RUN mkdir -p /var/sockets
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -ldflags="-s -w -extldflags '-static' -X main.GOMEMLIMIT=256MiB -X runtime.defaultGOGC=50" -trimpath -gcflags="-l=4" -asmflags=-trimpath -o bin/main app/gopherbook/main.go
# Build with CGO and increased WASM memory limits
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build \
-a \
-ldflags="-s -w -linkmode external -extldflags '-static' -X main.GOMEMLIMIT=512MiB -X runtime.defaultGOGC=50" \
-trimpath \
-o bin/main app/gopherbook/main.go
RUN upx --best --ultra-brute bin/main
RUN chmod +x bin/main
# Final stage with Chainguard static
FROM cgr.dev/chainguard/static:latest
WORKDIR /app
# Copy the binary
COPY --from=builder /app/bin/main ./bin/main
# Create directories that will be mounted and set ownership
EXPOSE 8080
USER root:root
CMD ["./bin/main"]