-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
46 lines (35 loc) · 1.45 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
FROM node:21-alpine@sha256:78c45726ea205bbe2f23889470f03b46ac988d14b6d813d095e2e9909f586f93 AS node-builder
WORKDIR /app/ui
COPY ui ./
RUN npm install && npm run build
FROM golang:1.23-bookworm@sha256:1a5326b07cbab12f4fd7800425f2cf25ff2bd62c404ef41b56cb99669a710a83 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 \
&& dpkg --add-architecture amd64 && apt-get update && \
apt-get install -y --no-install-recommends \
minify:amd64=2.12.4-2 \
libwebp-dev:amd64=1.2.4-0.2+deb12u1 \
&& 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@sha256:42d15c647a762d3ce3a67eab394220f5268915d6ddba9006871e16e4698c3a24 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"]