-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
48 lines (32 loc) · 1.11 KB
/
Copy pathDockerfile
File metadata and controls
48 lines (32 loc) · 1.11 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
FROM golang:1.24 AS builder
# Build-time version string (git tag > branch > SHA), passed in by CI
ARG VERSION=dev
# Install Node.js and make
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs make
WORKDIR /app
# Copy dependency files first for better caching
COPY go.mod go.sum package.json package-lock.json* Makefile ./
# Install dependencies
RUN make docker-deps
# Copy source
COPY . .
# Flatten directory structure if nested 'spotter' folder exists
# This handles the case where source files were generated into a subdirectory
RUN if [ -d "spotter" ]; then cp -r spotter/* . && rm -rf spotter; fi
# Generate code (Ent schemas and Templ templates)
RUN make generate
# Build CSS
RUN make css
# Build binary with version injected
RUN make build-binary VERSION=${VERSION}
# Runtime Stage
FROM debian:bookworm-slim
WORKDIR /app
# Install certificates
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
# Copy artifacts
COPY --from=builder /app/spotter-server .
COPY --from=builder /app/static ./static
EXPOSE 8080
CMD ["./spotter-server"]