-
-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathDockerfile
More file actions
46 lines (35 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
46 lines (35 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Build stage with multi-arch support
FROM --platform=$BUILDPLATFORM golang:1.26-alpine AS builder
WORKDIR /go/src/app
RUN apk update && apk add upx
ARG VERSION=main
ARG BUILD="N/A"
ARG TARGETPLATFORM
ARG BUILDPLATFORM
# Parse target platform
RUN case "$TARGETPLATFORM" in \
"linux/amd64") export GOARCH=amd64 ;; \
"linux/arm64") export GOARCH=arm64 ;; \
"linux/arm/v7") export GOARCH=arm GOARM=7 ;; \
"linux/386") export GOARCH=386 ;; \
*) export GOARCH=amd64 ;; \
esac && echo "GOARCH=$GOARCH" > /tmp/buildenv && echo "GOARM=${GOARM}" >> /tmp/buildenv
ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
COPY . /go/src/app/
RUN . /tmp/buildenv && \
go build -a -installsuffix cgo \
-ldflags="-w -s -X github.com/bakito/sealed-secrets-web/pkg/version.Version=${VERSION} -X github.com/bakito/sealed-secrets-web/pkg/version.Build=${BUILD}" \
-o sealed-secrets-web . && \
upx -q sealed-secrets-web
# Final application image
FROM alpine:latest
WORKDIR /opt/go
LABEL maintainer="bakito <github@bakito.ch>" \
org.opencontainers.image.description="A web interface for Sealed Secrets by Bitnami."
EXPOSE 8080
RUN apk add --no-cache dumb-init
COPY --from=builder /go/src/app/sealed-secrets-web /opt/go/sealed-secrets-web
USER 1001
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/opt/go/sealed-secrets-web"]