mirror of
https://codeberg.org/gigirassy/pinata
synced 2026-08-30 23:37:40 +00:00
Update Dockerfile
This commit is contained in:
+13
-17
@@ -1,39 +1,35 @@
|
|||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1.4
|
||||||
FROM --platform=$BUILDPLATFORM golang:1.24.8-alpine AS builder
|
FROM --platform=$BUILDPLATFORM tinygo/tinygo:0.39.0 AS builder
|
||||||
|
|
||||||
ARG TARGETOS
|
ARG TARGETOS
|
||||||
ARG TARGETARCH
|
ARG TARGETARCH
|
||||||
ARG TARGETVARIANT
|
|
||||||
|
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
# cache go mod download between builds (requires BuildKit)
|
# Copy go modules
|
||||||
COPY go.mod ./
|
COPY go.mod ./
|
||||||
RUN apk add --no-cache ca-certificates git
|
# TinyGo uses go modules too
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN tinygo mod download
|
||||||
--mount=type=cache,target=/go/pkg/mod \
|
|
||||||
go mod download
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN rm -rf screenies .github
|
RUN rm -rf screenies .github
|
||||||
|
|
||||||
# Static, trimmed, stripped build. Note: removed -gcflags="all=-l"
|
# Build with TinyGo
|
||||||
RUN CGO_ENABLED=0 \
|
RUN tinygo build \
|
||||||
GOOS=${TARGETOS:-linux} \
|
-o /pinata \
|
||||||
GOARCH=${TARGETARCH:-amd64} \
|
-target linux/${TARGETARCH} \
|
||||||
go build -trimpath \
|
-opt=z \
|
||||||
-ldflags="-s -w -extldflags '-static' -buildid=''" \
|
-no-debug \
|
||||||
-o /pinata ./main.go
|
./main.go
|
||||||
|
|
||||||
FROM scratch AS runtime
|
FROM scratch AS runtime
|
||||||
# copy binary and CA certs only
|
|
||||||
COPY --from=builder /pinata /pinata
|
COPY --from=builder /pinata /pinata
|
||||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||||
|
|
||||||
# unprivileged user (optional)
|
|
||||||
USER 65532
|
USER 65532
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
|
# Memory tuning
|
||||||
ENV GOMEMLIMIT=8MiB \
|
ENV GOMEMLIMIT=8MiB \
|
||||||
GOGC=20
|
GOGC=20
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user