Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
80 lines (76 loc) · 4.08 KB
/
Copy pathDockerfile
File metadata and controls
80 lines (76 loc) · 4.08 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
# syntax=docker/dockerfile:1.27.1@sha256:4edf897a3ffa55b89f906fc8cc78afdb3f1834cc9c7083565e611a8a7d5fe99e
ARG BUILDPLATFORM
FROM --platform=$BUILDPLATFORM node:26.13.1-alpine@sha256:6bd9ab43c0ec0190ca7b2d193906cb8b7edf6e7f4afa43ddeccd6452710bffb5 AS web-build
WORKDIR /src/web
COPY web/package.json web/package-lock.json ./
RUN --mount=type=cache,target=/root/.npm \
--mount=type=secret,id=https_proxy,required=false \
sh -eu -c 'if [ -f /run/secrets/https_proxy ]; then export HTTPS_PROXY="$(cat /run/secrets/https_proxy)"; fi; npm ci'
COPY web/index.html web/tsconfig.json web/vite.config.ts ./
COPY web/scripts/ ./scripts/
COPY web/src/ ./src/
COPY web/public/ ./public/
# Public assets can retain a restrictive source checkout's mode (for example 0600).
# The runtime is non-root: normalize only the generated, publicly served tree.
RUN npm run build \
&& find dist -type d -exec chmod 0755 {} + \
&& find dist -type f -exec chmod 0644 {} +
FROM --platform=$BUILDPLATFORM golang:1.27.4-alpine@sha256:0a5f7fe796599ff487605987432e7619ae45beeb2fba4c2ce0b907879932aebf AS go-build
ARG TARGETOS=linux
ARG TARGETARCH
ARG VERSION=dev
WORKDIR /src
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=secret,id=https_proxy,required=false \
sh -eu -c 'if [ -f /run/secrets/https_proxy ]; then export HTTPS_PROXY="$(cat /run/secrets/https_proxy)"; fi; go mod download'
COPY cmd/ ./cmd/
COPY internal/ ./internal/
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=secret,id=https_proxy,required=false \
sh -eu -c 'if [ -f /run/secrets/https_proxy ]; then export HTTPS_PROXY="$(cat /run/secrets/https_proxy)"; fi; \
CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \
go build -trimpath \
-ldflags="-s -w -X github.com/kejilion/kejilion-panel/internal/version.Version=${VERSION}" \
-o /out/paneld ./cmd/paneld; \
CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \
go build -trimpath \
-ldflags="-s -w -X github.com/kejilion/kejilion-panel/internal/version.Version=${VERSION}" \
-o /out/kejilion-agent ./cmd/kejilion-agent'
FROM scratch
ARG VERSION=dev
ARG REVISION=unknown
LABEL org.opencontainers.image.title="KPanel" \
org.opencontainers.image.description="Safe web management plane for kejilion.sh hosts" \
org.opencontainers.image.url="https://hub.docker.com/r/kjlion/kejilion-panel" \
org.opencontainers.image.source="https://github.com/kejilion/KPanel" \
org.opencontainers.image.licenses="AGPL-3.0-only" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.revision="${REVISION}" \
io.kejilion.kpanel.update-freeze="1" \
io.kejilion.script.revision="1faee13f3faef164efbfa899e244fc19ad58aaff" \
io.kejilion.script.sha256="5c5acccac56bba480046f28ac0d5d34af736fcfb5ab187647684b52c6689ad23"
COPY --from=go-build /out/paneld /paneld
COPY --from=go-build /out/kejilion-agent /release/kejilion-agent
COPY --from=go-build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
ADD --checksum=sha256:5c5acccac56bba480046f28ac0d5d34af736fcfb5ab187647684b52c6689ad23 \
https://raw.githubusercontent.com/kejilion/sh/1faee13f3faef164efbfa899e244fc19ad58aaff/kejilion.sh \
/release/kejilion.sh
COPY --from=web-build /src/web/dist /app/web
COPY VERSION /release/VERSION
COPY packaging/kejilion-app/kpanel.conf /release/kpanel.conf
COPY LICENSE /licenses/LICENSE
COPY NOTICE /licenses/NOTICE
COPY LICENSES/ /licenses/third-party/
COPY THIRD_PARTY_NOTICES.md /licenses/THIRD_PARTY_NOTICES.md
COPY TRADEMARKS.md /licenses/TRADEMARKS.md
COPY deploy/compose/compose.yml /release/compose.yml
COPY deploy/compose/direct-port.yml /release/direct-port.yml
COPY deploy/compose/.env.example /release/panel.env.example
COPY deploy/systemd/kejilion-agent.service /release/kejilion-agent.service
COPY deploy/systemd/agent.env.example /release/agent.env.example
USER 65532:65532
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 CMD ["/paneld", "healthcheck"]
ENTRYPOINT ["/paneld"]