-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patharch.dockerfile
More file actions
104 lines (85 loc) · 3.42 KB
/
Copy patharch.dockerfile
File metadata and controls
104 lines (85 loc) · 3.42 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# ╔═════════════════════════════════════════════════════╗
# ║ SETUP ║
# ╚═════════════════════════════════════════════════════╝
# GLOBAL
ARG APP_UID= \
APP_GID= \
APP_GO_VERSION=0
# :: FOREIGN IMAGES
FROM 11notes/distroless AS distroless
FROM 11notes/distroless:nc AS distroless-nc
# ╔═════════════════════════════════════════════════════╗
# ║ BUILD ║
# ╚═════════════════════════════════════════════════════╝
# :: ENTRYPOINT
FROM 11notes/go:${APP_GO_VERSION} AS entrypoint
COPY ./build /
RUN set -ex; \
cd /go/entrypoint; \
eleven go build /entrypoint main.go; \
eleven distroless /entrypoint;
# :: SSHPIPER
FROM 11notes/go:${APP_GO_VERSION} AS build
ARG APP_VERSION \
BUILD_ROOT=/go/sshpiper \
BUILD_SRC=tg123/sshpiper.git
RUN set -ex; \
eleven git clone ${BUILD_SRC} v${APP_VERSION};
RUN set -ex; \
cd ${BUILD_ROOT}; \
eleven go patch google.golang.org/grpc v1.79.3 CVE-2026-33186; \
eleven go patch golang.org/x/net v0.55.0 CVE-2026-39821;
COPY ./build/go/sshpiper /go/sshpiper
RUN set -ex; \
cd ${BUILD_ROOT}; \
mkdir -p /tmp/sshpiper; \
rm -rf ./plugin/simplemath; \
go mod tidy; \
go build -tags full -ldflags="-extldflags=-static -X main.mainver=${APP_VERSION}" -o /tmp/sshpiper ./cmd/...; \
go build -tags full -ldflags="-extldflags=-static" -o /tmp/sshpiper ./plugin/...;
RUN set -ex; \
cd /tmp/sshpiper; \
for BIN in *; do \
eleven distroless ${BIN}; \
done;
# :: FILE SYSTEM
FROM alpine AS file-system
ARG APP_ROOT
RUN set -ex; \
mkdir -p /distroless${APP_ROOT}/var;
# ╔═════════════════════════════════════════════════════╗
# ║ IMAGE ║
# ╚═════════════════════════════════════════════════════╝
# :: HEADER
FROM scratch
# :: default arguments
ARG TARGETPLATFORM \
TARGETOS \
TARGETARCH \
TARGETVARIANT \
APP_IMAGE \
APP_NAME \
APP_VERSION \
APP_ROOT \
APP_UID \
APP_GID \
APP_NO_CACHE
# :: default environment
ENV APP_IMAGE=${APP_IMAGE} \
APP_NAME=${APP_NAME} \
APP_VERSION=${APP_VERSION} \
APP_ROOT=${APP_ROOT}
# :: multi-stage
COPY --from=distroless / /
COPY --from=distroless-nc / /
COPY --from=build /distroless/ /
COPY --from=entrypoint /distroless/ /
COPY --from=file-system --chown=${APP_UID}:${APP_GID} /distroless/ /
# :: PERSISTENT DATA
VOLUME ["${APP_ROOT}/var"]
# :: MONITORING
HEALTHCHECK --interval=5s --timeout=2s --start-period=5s \
CMD ["/usr/local/bin/nc", "-z", "127.0.0.1", "22"]
# :: EXECUTE
USER ${APP_UID}:${APP_GID}
ENTRYPOINT ["/usr/local/bin/entrypoint"]