-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (32 loc) · 1.3 KB
/
Dockerfile
File metadata and controls
64 lines (32 loc) · 1.3 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
FROM oven/bun:1.1.27-debian@sha256:c74cf88ac2f309414b4c9a3d33cbb05b67abcc9f489eb6adc02c3c0b37778d76 AS bun
WORKDIR /app
COPY package.json bun.lockb tailwind.config.js tsconfig.json style.css ./
COPY ./internal/template/*.templ ./internal/template/
RUN bun install
RUN bunx tailwindcss -i ./style.css -o ./public/style.css
FROM golang:1.22-bullseye@sha256:583d5af8289d30de50aa0dcf4985d8b8746e52622becd6e1a62cfe191d5275a5 AS build
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=bun /app/public/style.css /app/public/style.css
RUN go install github.com/a-h/templ/cmd/templ@v0.2.680
RUN templ generate
RUN go build \
-ldflags="-linkmode external -extldflags -static -X 'main.BUILDTIME=$(date --iso-8601=seconds --utc)'" \
-o api \
./cmd/api/main.go
RUN useradd -u 1001 crocoderdev
FROM scratch
WORKDIR /
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build /app/api /api
COPY --from=build /app/public /public
COPY --from=build /app/internal/template/script /internal/template/script
COPY --from=build /app/internal/template/stylesheet /internal/template/stylesheet
COPY --from=build /app/internal/template/demo.html /internal/template/demo.html
USER crocoderdev
EXPOSE 80
EXPOSE 443
CMD ["/api"]