forked from root-gg/plik
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
95 lines (67 loc) · 2.74 KB
/
Dockerfile
File metadata and controls
95 lines (67 loc) · 2.74 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
##################################################################################
FROM --platform=$BUILDPLATFORM node:24-alpine AS plik-frontend-builder
# Install needed binaries
RUN apk add --no-cache git make bash
# Add the source code
COPY Makefile .
COPY webapp /webapp
RUN make clean-frontend frontend
##################################################################################
FROM --platform=$BUILDPLATFORM golang:1-bookworm AS plik-client-builder
# Prepare the source location
RUN mkdir -p /go/src/github.com/root-gg/plik
WORKDIR /go/src/github.com/root-gg/plik
ARG CLIENT_TARGETS=""
ENV CLIENT_TARGETS=$CLIENT_TARGETS
ARG VERSION=""
ENV VERSION=$VERSION
# Add the source code ( see .dockerignore )
COPY . .
# Build all clients once ( pure Go cross-compilation, no CGO needed )
RUN releaser/build_clients.sh
##################################################################################
FROM --platform=$BUILDPLATFORM golang:1-bookworm AS plik-builder
# Install needed binaries for server cross-compilation
RUN apt-get update && apt-get install -y build-essential crossbuild-essential-armhf crossbuild-essential-armel crossbuild-essential-arm64 crossbuild-essential-i386
# Prepare the source location
RUN mkdir -p /go/src/github.com/root-gg/plik
WORKDIR /go/src/github.com/root-gg/plik
# Copy webapp build from previous stage
COPY --from=plik-frontend-builder /webapp/dist webapp/dist
# Copy pre-built clients from previous stage
COPY --from=plik-client-builder /go/src/github.com/root-gg/plik/clients clients
ARG TARGETOS TARGETARCH TARGETVARIANT CC
ENV TARGETOS=$TARGETOS
ENV TARGETARCH=$TARGETARCH
ENV TARGETVARIANT=$TARGETVARIANT
ENV CC=$CC
ARG VERSION=""
ENV VERSION=$VERSION
# Add the source code ( see .dockerignore )
COPY . .
RUN releaser/build_server_release.sh
##################################################################################
FROM scratch AS plik-clients-archive
COPY --from=plik-client-builder --chown=1000:1000 /go/src/github.com/root-gg/plik/clients /
##################################################################################
FROM scratch AS plik-release-archive
COPY --from=plik-builder --chown=1000:1000 /go/src/github.com/root-gg/plik/plik-server-*.tar.gz /
##################################################################################
FROM alpine:3.21 AS plik-image
RUN apk add --no-cache ca-certificates
# Create plik user
ENV USER=plik
ENV UID=1000
# See https://stackoverflow.com/a/55757473/12429735
RUN adduser \
--disabled-password \
--gecos "" \
--home "/home/plik" \
--shell "/bin/false" \
--uid "${UID}" \
"${USER}"
COPY --from=plik-builder --chown=1000:1000 /go/src/github.com/root-gg/plik/release /home/plik/
EXPOSE 8080
USER plik
WORKDIR /home/plik/server
CMD ["./plikd"]