-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile
68 lines (50 loc) · 1.86 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 JSBUILD
COPY package.json package-lock.json rollup.config.js ./
RUN npm ci
COPY resources/js resources/js
RUN npm run build
FROM --platform=$TARGETPLATFORM golang:1.21-alpine3.18 as GOBUILD
# Important:
# Because this is a CGO enabled package, you are required to set it as 1.
ENV CGO_ENABLED=1
RUN apk add --no-cache \
# Important: required for go-sqlite3
gcc \
# Required for Alpine
musl-dev
# Force the go compiler to use modules
ENV GO111MODULE=on
ENV GOOS=linux
# Create the user and group files to run unprivileged
RUN mkdir /user && \
echo 'mokintoken:x:65534:65534:mokintoken:/:' > /user/passwd && \
echo 'mokintoken:x:65534:' > /user/group
RUN apk update && apk add --no-cache git ca-certificates tzdata gcc g++ openssh-client
RUN mkdir /build
WORKDIR /build
COPY go.mod go.sum ./
RUN go mod download
RUN mkdir database && touch database/mokintoken.sqlite
COPY healthcheck ./healthcheck
RUN go build -o healthcheckCommand ./healthcheck/main.go
COPY *.go ./
RUN go get ./
RUN go build -o mokintoken ./mokintoken.go
# FROM scratch AS final would be nice, ned cgo for sqlite3 lib
FROM alpine:3.18 AS final
LABEL author="John Cena"
WORKDIR /app
# Import the user and group files
COPY --from=GOBUILD /user/group /user/passwd /etc/
COPY --from=GOBUILD /build/mokintoken ./
COPY --from=GOBUILD /build/healthcheckCommand ./
COPY --from=GOBUILD --chown=mokintoken:mokintoken /build/database ./database
COPY --from=JSBUILD assets/* ./assets/
COPY ./views ./views
USER mokintoken:mokintoken
EXPOSE 8080
ENV CLEARNET "https://mokintoken.ramsay.xyz"
ENV DARKNET "http://mokinan4qvxi4ragyzgkewrmnnqslkcdglk6v5zruknwnnuvv2lu5uad.onion"
ENTRYPOINT ["/app/mokintoken"]
VOLUME /app/database/mokintoken.sqlite
HEALTHCHECK --interval=30s --timeout=1s --start-period=5s --retries=3 CMD [ "/app/healthcheckCommand" ]