-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
57 lines (44 loc) · 1.68 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
46
47
48
49
50
51
52
53
54
55
56
57
###############################################################################
# First stage:
# - Building the COSI OSP using the default Go image.
###############################################################################
FROM --platform=${BUILDPLATFORM} docker.io/library/golang:1.21.3 AS builder
# Set the working directory.
WORKDIR /cosi-osp
# Copy the Go Modules manifests.
COPY go.mod go.mod
COPY go.sum go.sum
# Cache deps before building and copying source, so that we don't need to re-download
# as much and so theat source changes don't invalidate our downloaded layer.
RUN go mod download
# Copy the source.
COPY main.go main.go
COPY servers/ servers/
COPY internal/ internal/
# Disable CGO.
ENV CGO_ENABLED=0
# Build the image.
RUN go build -o build/cosi-osp main.go
###############################################################################
# Second Stage:
# - Runtime image.
#
# NOTE: you should replace the latest with specific digest, to ensure that
# builds are consistent.
###############################################################################
FROM --platform=${BUILDPLATFORM} gcr.io/distroless/static:latest AS runtime
# Set the working directory.
WORKDIR /cosi
# Set volume mount point for COSI socket.
VOLUME [ "/var/lib/cosi" ]
# Expose the healthcheck port.
EXPOSE 8080
# Define a healthcheck for the container.
HEALTHCHECK --interval=30s --timeout=15s --retries=3 \
CMD [ "/usr/bin/cosi-osp", "--healthcheck" ]
# Set the default environment.
ENV COSI_ENDPOINT="unix:///var/lib/cosi/cosi.sock"
COPY --from=builder /cosi-osp/build/cosi-osp /usr/bin/cosi-osp
# Set the correct entrypoint and command arguments.
ENTRYPOINT [ "/usr/bin/cosi-osp" ]
CMD []