Skip to content

Commit 258b772

Browse files
committed
moving frontend end build to docker
1 parent 1969970 commit 258b772

8 files changed

Lines changed: 48 additions & 4514 deletions

File tree

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ dist/
77
config.yaml
88

99
*_templ.go
10+
11+
node_modules/
12+
frontend/node_modules/
13+
14+
frontend/public/assets/css
15+
frontend/public/assets/js/kiosk.js

Dockerfile

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
# Builder
1+
# Frontend Base Image
2+
FROM node:20-slim AS frontend-base
3+
4+
ENV PNPM_HOME="/pnpm"
5+
ENV PATH="$PNPM_HOME:$PATH"
6+
RUN corepack enable
7+
COPY . /app
8+
WORKDIR /app/frontend
9+
10+
# Frontend Dependencies
11+
FROM frontend-base AS frontend-prod-deps
12+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --prod --frozen-lockfile
13+
14+
# Frontend Build
15+
FROM frontend-base AS frontend-build
16+
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile
17+
RUN pnpm css && pnpm js
18+
19+
# Go Builder
220
FROM --platform=$BUILDPLATFORM golang:1.24.3-alpine AS build
321

422
ARG VERSION=demo
@@ -8,14 +26,16 @@ ARG TARGETARCH
826
WORKDIR /app
927

1028
COPY . .
29+
COPY --from=frontend-build /app/frontend/public/assets/css /app/frontend/public/assets/css
30+
COPY --from=frontend-build /app/frontend/public/assets/js/kiosk.js /app/frontend/public/assets/js/kiosk.js
1131

1232
RUN go mod download
1333
RUN go tool templ generate
1434

1535
RUN CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -a -installsuffix cgo -ldflags "-X main.version=${VERSION}" -o dist/kiosk .
1636

1737
# Release
18-
FROM alpine:latest
38+
FROM alpine:latest
1939

2040
ENV TZ=Europe/London
2141

0 commit comments

Comments
 (0)