-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
54 lines (28 loc) · 931 Bytes
/
Dockerfile
File metadata and controls
54 lines (28 loc) · 931 Bytes
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
FROM oven/bun:1.0.21-debian as bun
WORKDIR /app
COPY tailwind.config.js style.css ./
COPY ./internals/templates/*.templ ./internals/templates/
RUN bunx tailwindcss@latest -i ./style.css -o ./dist/style.css
FROM golang:1.21.5-bullseye as builder
WORKDIR /app
COPY go.mod go.sum ./
RUN --mount=type=cache,target=/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \
go mod download
RUN useradd -u 1001 crocoder
COPY . .
RUN go install github.com/a-h/templ/cmd/templ@e98db353f87ebedea804cb3dc3200a826afb8904
RUN templ generate
RUN go build \
-ldflags="-linkmode external -extldflags -static" \
-o web \
./cmd/web/main.go
FROM scratch
WORKDIR /
COPY --from=bun /app/dist/style.css /dist/style.css
COPY --from=builder /app/web /web
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /etc/passwd /etc/passwd
USER crocoder
EXPOSE 3000
CMD ["/web"]