forked from scottillogical/cogito
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
41 lines (29 loc) · 821 Bytes
/
Copy pathDockerfile
File metadata and controls
41 lines (29 loc) · 821 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
FROM golang:1.23-alpine AS builder
ARG BUILD_INFO
ENV GOPATH=/root/go CGO_ENABLED=0
WORKDIR /code
#
# Optimize downloading of dependencies only when they are needed.
# This requires to _first_ copy only these two files, run `go mod download`,
# and _then_ copy the rest of the source code.
#
COPY go.mod go.sum ./
RUN go mod download
#
# Build.
#
COPY . .
RUN go test -short ./...
RUN go install \
-ldflags "-w -X 'github.com/Pix4D/cogito/cogito.buildinfo=$BUILD_INFO'" \
./cmd/cogito
#
# The final image
#
FROM alpine
RUN apk --no-cache add ca-certificates
RUN mkdir -p /opt/resource
COPY --from=builder /root/go/bin/* /opt/resource/
RUN ln -s /opt/resource/cogito /opt/resource/check && \
ln -s /opt/resource/cogito /opt/resource/in && \
ln -s /opt/resource/cogito /opt/resource/out