-
Notifications
You must be signed in to change notification settings - Fork 40
/
Dockerfile
43 lines (34 loc) · 1.09 KB
/
Dockerfile
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
# https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
ARG TARGETOS
ARG TARGETARCH
ARG TARGETPLATFORM
# Build the manager binary
FROM golang:1.23 as builder
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
# since we use vendoring we don't need to redownload our dependencies every time. Instead we can simply
# reuse our vendored directory and verify everything is good. If not we can abort here and ask for a revendor.
COPY vendor vendor/
RUN go mod verify
# Copy the go source
COPY api/ api/
COPY cmd/ cmd/
COPY internal/ internal/
# Build
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -mod=vendor --ldflags "-s -w" -a -o lvms cmd/main.go
FROM --platform=$TARGETPLATFORM fedora:latest
RUN dnf update -y && \
dnf install --nodocs --noplugins -y \
util-linux \
e2fsprogs \
xfsprogs \
glibc && \
dnf clean all
RUN [ -d /run/lock ] || mkdir /run/lock
WORKDIR /
COPY --from=builder /workspace/lvms .
USER 65532:65532
# '/lvms' is the entrypoint for all LVMS binaries
ENTRYPOINT ["/lvms"]