feat: compile templ files in docker build
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -40,3 +40,5 @@ atlas.hcl
|
||||
.scannerwork
|
||||
Backend/logs
|
||||
.worktime.txt
|
||||
|
||||
*_templ.go
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
db
|
||||
Dockerfile
|
||||
*_templ.go
|
||||
|
||||
@@ -1,16 +1,24 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM --platform=$BUILDPLATFORM golang:alpine AS build
|
||||
FROM --platform=$BUILDPLATFORM golang:alpine AS base
|
||||
ARG TARGETOS
|
||||
ARG TARGETARCH
|
||||
ENV CGO_ENABLED=0 \
|
||||
GOOS=$TARGETOS \
|
||||
GOARCH=$TARGETARCH
|
||||
|
||||
FROM base AS fetch-stage
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum /app/
|
||||
RUN go mod download && go mod verify
|
||||
|
||||
COPY . .
|
||||
FROM ghcr.io/a-h/templ:latest AS generate-stage
|
||||
COPY --chown=65532:65532 . /app
|
||||
WORKDIR /app
|
||||
RUN ["templ", "generate"]
|
||||
|
||||
FROM base AS build
|
||||
COPY --from=generate-stage /app /app
|
||||
WORKDIR /app
|
||||
RUN go build -o server .
|
||||
|
||||
FROM alpine:3.22
|
||||
|
||||
Reference in New Issue
Block a user