Newer
Older
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
# docker buildx build --platform linux/amd64,linux/arm64 -t datastropheregistry.azurecr.io/query-orchestrator . --push --ssh default
# STAGE 1
FROM golang:1.16
ARG TARGETARCH
ARG TARGETOS
WORKDIR /app
# Use SSH instead of HTTPS
RUN echo "[url \"git@git.science.uu.nl:\"]\n\tinsteadOf = https://git.science.uu.nl/" >> /root/.gitconfig
# Turn off strict host key checking
RUN mkdir /root/.ssh && echo "StrictHostKeyChecking no " > /root/.ssh/config
# Copy go files into the image
COPY go.mod ./
COPY go.sum ./
COPY cmd/ ./cmd/
COPY internal/ ./internal/
COPY pkg/ ./pkg/
# Gather dependencies
RUN --mount=type=ssh go mod download
# Compile for the target architecture and operating system
# Add SSH mount as this operation requires access to private repos
RUN GOARCH=${TARGETARCH} GOOS=${TARGETOS} CGO_ENABLED=0 go build -o ./main ./cmd/query-orchestrator/
# STAGE 2
FROM busybox
WORKDIR /app
# Copy the built binary into this image
COPY --from=0 /app/main ./
# Run the binary
CMD ./main