-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile
57 lines (42 loc) · 1.61 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
FROM golang:1.20.5-buster as builder
# Install deps
RUN apt-get update && apt-get install -y \
libssl-dev \
ca-certificates \
fuse
ENV SRC_DIR /build
# Download packages first so they can be cached.
COPY go.mod go.sum $SRC_DIR/
RUN cd $SRC_DIR \
&& go mod download
COPY . $SRC_DIR
RUN cd $SRC_DIR/cmd/cas \
&& CGO_ENABLED=0 GOOS=linux GOTAGS=openssl go build -a -o cas .
# Get tini, a very minimal init daemon for containers.
ENV TINI_VERSION v0.19.0
RUN set -eux; \
dpkgArch="$(dpkg --print-architecture)"; \
case "${dpkgArch##*-}" in \
"amd64" | "armhf" | "arm64") tiniArch="tini-static-$dpkgArch" ;;\
*) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \
esac; \
cd /tmp \
&& wget -q -O tini https://github.com/krallin/tini/releases/download/$TINI_VERSION/$tiniArch \
&& chmod +x tini
# Now comes the actual target image, which aims to be as small as possible.
FROM busybox:1.31.1-glibc as target
COPY --from=builder /tmp/tini /sbin/tini
COPY --from=builder /etc/ssl/certs /etc/ssl/certs
# This shared lib (part of glibc) doesn't seem to be included with busybox.
COPY --from=builder /lib/*-linux-gnu*/libdl.so.2 /lib/
# Copy over SSL libraries.
COPY --from=builder /usr/lib/*-linux-gnu*/libssl.so* /usr/lib/
COPY --from=builder /usr/lib/*-linux-gnu*/libcrypto.so* /usr/lib/
# Get the CAS binary and environment variables from the build container.
ENV SRC_DIR /build
COPY --from=builder $SRC_DIR/env/* /usr/local/bin/cas/env/
COPY --from=builder $SRC_DIR/cmd/cas/cas /usr/local/bin/cas/cas
EXPOSE 8080
ENV ENV_TAG dev
WORKDIR /usr/local/bin/cas
CMD ["/sbin/tini", "-s", "./cas"]