-
Notifications
You must be signed in to change notification settings - Fork 170
/
Dockerfile
68 lines (49 loc) · 1.87 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
58
59
60
61
62
63
64
65
66
67
68
##################################################################################
FROM --platform=$BUILDPLATFORM node:20-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-bullseye AS plik-builder
# Install needed binaries
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
ARG CLIENT_TARGETS=""
ENV CLIENT_TARGETS=$CLIENT_TARGETS
ARG TARGETOS TARGETARCH TARGETVARIANT CC
ENV TARGETOS=$TARGETOS
ENV TARGETARCH=$TARGETARCH
ENV TARGETVARIANT=$TARGETVARIANT
ENV CC=$CC
# Add the source code ( see .dockerignore )
COPY . .
RUN releaser/releaser.sh
##################################################################################
FROM scratch AS plik-release-archive
COPY --from=plik-builder --chown=1000:1000 /go/src/github.com/root-gg/plik/plik-*.tar.gz /
##################################################################################
FROM alpine:3.18 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