-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
49 lines (36 loc) · 1.04 KB
/
Dockerfile
File metadata and controls
49 lines (36 loc) · 1.04 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
# Stage 1: Build frontend assets with Node.js
FROM node:22-alpine AS frontend-builder
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY assets/ ./assets/
COPY public/ ./public/
COPY app/views/ ./app/views/
COPY vite.config.js ./
RUN npm run build
# Stage 2: Build Go application
FROM golang:1.24-alpine AS backend-builder
WORKDIR /app
RUN apk add curl
RUN mkdir -p bin && \
curl -fsSL -o bin/dbmate https://github.com/amacneil/dbmate/releases/download/v2.26.0/dbmate-linux-amd64 && \
chmod +x bin/dbmate
COPY go.mod go.sum ./
RUN go mod download
# Embedded files
COPY --from=frontend-builder /app/dist ./dist
COPY sql/pragmas.sql ./sql/
COPY locales ./locales/
# Go source files
COPY app ./app/
COPY main.go ./
RUN CGO_ENABLED=0 GOOS=linux go build -o bin/app .
# Stage 3: Runtime image
FROM alpine:latest
RUN apk add --no-cache sqlite
COPY --from=backend-builder /app/bin/dbmate /dbmate
COPY sql/migrations /migrations
COPY --from=backend-builder /app/bin/app /app
COPY deploy/run.sh /run.sh
EXPOSE 3000
CMD ["/run.sh"]