-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
59 lines (53 loc) · 2.25 KB
/
Dockerfile
File metadata and controls
59 lines (53 loc) · 2.25 KB
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
# syntax = docker/dockerfile:1.2.1
FROM --platform=${BUILDPLATFORM} docker.io/golang:1.16.4-buster AS base
ARG BUILDPLATFORM
WORKDIR /usr/src/cosi-driver-sample
COPY go.mod go.sum ./
RUN go mod download
FROM base AS build
ARG TARGETOS
ARG TARGETARCH
RUN --mount=target=. \
CGO_ENABLED=0 \
GOOS=${TARGETOS} \
GOARCH=${TARGETARCH} \
go build \
-mod=readonly \
-ldflags '-s -w -extldflags -static' \
-o /out/cosi-driver-sample \
./cmd/cosi-driver-sample/
FROM base AS test
ARG BUILDOS
ARG BUILDARCH
RUN --mount=target=. \
CGO_ENABLED=0 \
GOOS=${BUILDOS} \
GOARCH=${BUILDARCH} \
go build \
-mod=readonly \
-ldflags '-s -w -extldflags -static' \
-o /out/cosi-driver-sample \
./cmd/cosi-driver-sample \
&& \
rm -f /out/cosi-driver-sample
ENTRYPOINT ["go", "test", "-mod=readonly", "-v", "./..."]
# gcr.io/distroless/static:nonroot
FROM --platform=${TARGETPLATFORM} gcr.io/distroless/static@sha256:cd784033c94dd30546456f35de8e128390ae15c48cbee5eb7e3306857ec17631 as bin
ARG TARGETPLATFORM
LABEL org.opencontainers.image.authors="Nicolas Trangez <nicolas.trangez@scality.com>" \
org.opencontainers.image.url="https://github.com/scality/cosi-driver-sample" \
org.label-schema.url="https://github.com/scality/cosi-driver-sample" \
org.opencontainers.image.documentation="https://github.com/scality/cosi-driver-sample/blob/hack/README.md" \
org.label-schema.usage="https://github.com/scality/cosi-driver-sample/blob/hack/README.md" \
org.opencontainers.image.source="https://github.com/scality/cosi-driver-sample.git" \
org.label-schema.vcs-url="https://github.com/scality/cosi-driver-sample.git" \
org.opencontainers.image.vendor="Scality" \
org.label-schema.vendor="Scality" \
org.opencontainers.image.licenses="Apache-2.0" \
org.opencontainers.image.title="cosi-driver-sample" \
org.label-schema.name="cosi-driver-sample" \
org.opencontainers.image.description="A sample driver for COSI, the Container Object Storage Interface" \
org.label-schema.description="A sample driver for COSI, the Container Object Storage Interface" \
org.label-schema.schema-version="1.0"
COPY --from=build /out/cosi-driver-sample /
ENTRYPOINT ["/cosi-driver-sample"]