-
Notifications
You must be signed in to change notification settings - Fork 62
/
Dockerfile
45 lines (34 loc) · 1.33 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
44
45
FROM node:20 as build-deps
WORKDIR /usr/src/app
COPY ./frontend ./
RUN yarn install --network-timeout 1000000 && yarn build
# Build the manager binary
FROM --platform=${BUILDPLATFORM} golang:1.23 as builder
ARG TARGETOS
ARG TARGETARCH
RUN mkdir -p "$GOPATH/src/github.com/stakater/Forecastle"
WORKDIR "$GOPATH/src/github.com/stakater/Forecastle"
# Copy manifests
COPY . .
# Install Packr2
ARG PACKR_VERSION=2.7.1
ARG PACKR_FILENAME=packr_${PACKR_VERSION}_linux_386.tar.gz
ARG PACKR_URL=https://github.com/gobuffalo/packr/releases/download/v${PACKR_VERSION}/${PACKR_FILENAME}
RUN mkdir -p /tmp/packr/ && \
wget ${PACKR_URL} -O /tmp/packr/${PACKR_FILENAME} && \
tar -xzvf /tmp/packr/${PACKR_FILENAME} -C /tmp/packr/ && \
mv /tmp/packr/packr2 /usr/local/bin/packr2 && \
rm -rf /tmp/packr
# Copy dependencies
COPY --from=build-deps /usr/src/app/build ./frontend/build/
# Build
RUN go mod download && \
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} GO111MODULE=on packr2 build -a --installsuffix cgo --ldflags="-s" -o /Forecastle && \
packr2 clean
# Use distroless as minimal base image to package the Forecastle binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
FROM gcr.io/distroless/static:nonroot
WORKDIR /
COPY --from=builder /Forecastle .
USER nonroot:nonroot
ENTRYPOINT ["/Forecastle"]