forked from s3gw-tech/s3gw-cosi-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
74 lines (55 loc) · 2.38 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#########################################################################################
# Build
#########################################################################################
# First stage: building the driver executable.
FROM docker.io/library/golang:1.22.3 as builder
# Set the working directory.
WORKDIR /work
# Prepare dir so it can be copied over to runtime layer.
RUN mkdir -p /var/lib/cosi
# Copy the Go Modules manifests.
COPY go.mod go.mod
COPY go.sum go.sum
# Cache dep before building and copying source so that we don't need to re-download as
# much and so that source changes don't invalidate our downloaded layer.
RUN go mod download
# Copy the go source.
COPY Makefile Makefile
COPY cmd/ cmd/
COPY pkg/ pkg/
# Build.
RUN make build
#########################################################################################
# Runtime
#########################################################################################
# Second stage: building final environment for running the executable.
FROM gcr.io/distroless/static:latest AS runtime
# Copy the executable.
COPY --from=builder --chown=65532:65532 /work/bin/seaweedfs-cosi-driver /usr/bin/seaweedfs-cosi-driver
# Copy the volume directory with correct permissions, so driver can bind a socket there.
COPY --from=builder --chown=65532:65532 /var/lib/cosi /var/lib/cosi
# Set volume mount point for app socket.
VOLUME [ "/var/lib/cosi" ]
# Set the final UID:GID to non-root user.
USER 65532:65532
# Disable healthcheck.
HEALTHCHECK NONE
# Few Args for dynamically setting labels.
ARG QUAY_EXPIRATION=Never
ARG SEAWEEDFS_VERSION=Development
# Add labels.
## Standard opencontainers labels.
LABEL org.opencontainers.image.title="seaweedfs-cosi-driver"
LABEL org.opencontainers.image.description="COSI Driver for seaweedfs"
LABEL org.opencontainers.image.authors="seaweedfs maintainers"
LABEL org.opencontainers.image.vendor="seaweedfs-tech"
LABEL org.opencontainers.image.version="${SEAWEEDFS_VERSION}"
LABEL org.opencontainers.image.license="Apache-2.0"
LABEL org.opencontainers.image.source="github.com/seaweedfs/seaweedfs-cosi-driver"
LABEL org.opencontainers.image.documentation="https://seaweedfs.github.io/"
LABEL org.opencontainers.image.base.name="gcr.io/distroless/static:latest"
## Quay specific labels.
LABEL quay.expires-after="${QUAY_EXPIRATION}"
# Set the entrypoint.
ENTRYPOINT [ "/usr/bin/seaweedfs-cosi-driver" ]
CMD []