-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.template
44 lines (33 loc) · 1.12 KB
/
Dockerfile.template
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
FROM node:21-alpine AS node-builder
WORKDIR /app/ui
COPY ui ./
RUN npm install && npm run build
FROM golang:1.23-bookworm AS builder
WORKDIR /app
COPY go.mod go.sum Makefile ./
COPY vendor ./vendor
COPY cmd ./cmd
COPY internal ./internal
COPY assets ./assets
COPY --from=node-builder /app/public ./public
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Minify Assets
# hadolint ignore=DL3008
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
minify \
libwebp-dev \
&& find ./public -type f \( \
-name "*.html" \
-o -name '*.js' \
-o -name '*.css' \
\) \
-print0 | \
xargs -0 -I '{}' sh -c 'minify -o "{}" "{}"'
RUN CGO_ENABLED=1 GOOS=linux go build -ldflags="-s -w -linkmode 'external' -extldflags '-static'" -o ./bin/song-stitch cmd/*.go
FROM gcr.io/distroless/static-debian12:nonroot AS build-release-stage
WORKDIR /app
COPY --chown=nonroot:nonroot --from=builder /app/bin/song-stitch /app/song-stitch
COPY --chown=nonroot:nonroot --from=builder /app/public /app/public
COPY --chown=nonroot:nonroot assets/NotoSans-Bold.ttf assets/NotoSans-Regular.ttf /app/assets/
ENTRYPOINT ["/app/song-stitch"]