-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (34 loc) · 1009 Bytes
/
Dockerfile
File metadata and controls
48 lines (34 loc) · 1009 Bytes
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
47
48
# syntax = docker/dockerfile:experimental
#
# ----- Go Builder Image ------
#
FROM --platform=${BUILDPLATFORM} golang:1.24-alpine AS builder
# Only install essential tools for building
RUN apk add --no-cache git make ca-certificates
#
# ----- Build and Test Image -----
#
FROM --platform=${BUILDPLATFORM} builder AS build
# passed by buildkit
ARG TARGETOS
ARG TARGETARCH
# set working directory
RUN mkdir -p /go/src/app
WORKDIR /go/src/app
# load dependency
COPY go.mod .
COPY go.sum .
RUN --mount=type=cache,target=/go/mod go mod download
# copy sources
COPY . .
# test and build
RUN --mount=type=cache,target=/root/.cache/go-build TARGETOS=${TARGETOS} TARGETARCH=${TARGETARCH} make build
#
# ------ spotinfo release Docker image ------
#
FROM scratch
# copy CA certificates
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
# this is the last command since it's never cached
COPY --from=build /go/src/app/.bin/spotinfo /spotinfo
ENTRYPOINT ["/spotinfo"]