-
Notifications
You must be signed in to change notification settings - Fork 2
/
Dockerfile
29 lines (21 loc) · 821 Bytes
/
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
FROM --platform=${BUILDPLATFORM} golang:1.22 as build-env
ARG TARGETPLATFORM
ARG BUILDPLATFORM
ARG TARGETOS
ARG TARGETARCH
RUN apt-get install -yq --no-install-recommends git
# Copy source + vendor
COPY . /go/src/github.com/vincejv/gpon-parser
WORKDIR /go/src/github.com/vincejv/gpon-parser
# Compile go binaries
ENV GOPATH=/go
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on go build -v -a -ldflags "-s -w" -o /go/bin/gpon-parser .
# Build final image from alpine
FROM --platform=${TARGETPLATFORM} alpine:latest
RUN apk --update --no-cache add curl && rm -rf /var/cache/apk/*
COPY --from=build-env /go/bin/gpon-parser /usr/bin/gpon-parser
# Create a group and user
RUN addgroup -S gpon-parser && adduser -S gpon-parser -G gpon-parser
USER gpon-parser
ENTRYPOINT ["gpon-parser"]
EXPOSE 8092