forked from asciimoo/hister
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
92 lines (65 loc) · 2.05 KB
/
Copy pathDockerfile
File metadata and controls
92 lines (65 loc) · 2.05 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
FROM golang:1.24-bookworm AS builder
RUN apt-get update && apt-get install -y --no-install-recommends \
gcc \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*
# Switch workdir do build directory
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
# Install Node.js and npm for static asset build
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg \
&& rm -rf /var/lib/apt/lists/*
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - && \
apt-get install -y --no-install-recommends \
nodejs \
&& rm -rf /var/lib/apt/lists/*
# Build static assets
COPY . .
RUN go generate
# Enable CGO and build the application for Linux
RUN CGO_ENABLED=1 GOOS=linux go build \
-ldflags="-s -w" \
-o hister .
# Release stage(distroless-nonroot)
# latest & vx.x.x
FROM gcr.io/distroless/base-debian12:nonroot AS release
WORKDIR /hister
COPY --from=builder /app/hister .
USER 65532:65532
ENV HISTER_DATA_DIR=/hister/data
ENV HISTER_CONFIG=/hister/data/config.yml
ENV HISTER__SERVER__ADDRESS=0.0.0.0:4433
ENV HISTER__SERVER__BASE_URL=http://localhost:4433
EXPOSE 4433
ENTRYPOINT ["/hister/hister"]
CMD ["listen"]
# Release stage(distroless)
# latest-root & vx.x.x-root
FROM gcr.io/distroless/base-debian12 AS root
WORKDIR /hister
COPY --from=builder /app/hister .
USER root
ENV HISTER_DATA_DIR=/hister/data
ENV HISTER_CONFIG=/hister/data/config.yml
ENV HISTER__SERVER__ADDRESS=0.0.0.0:4433
ENV HISTER__SERVER__BASE_URL=http://localhost:4433
EXPOSE 4433
ENTRYPOINT ["/hister/hister"]
CMD ["listen"]
# Release stage(distroless-debug)
# latest-debug & vx.x.x-debug
FROM gcr.io/distroless/base-debian12:debug AS debug
WORKDIR /hister
COPY --from=builder /app/hister .
USER root
ENV HISTER_DATA_DIR=/hister/data
ENV HISTER_CONFIG=/hister/data/config.yml
ENV HISTER__SERVER__ADDRESS=0.0.0.0:4433
ENV HISTER__SERVER__BASE_URL=http://localhost:4433
EXPOSE 4433
ENTRYPOINT ["/hister/hister"]
CMD ["listen"]