-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (46 loc) · 1.8 KB
/
Dockerfile
File metadata and controls
64 lines (46 loc) · 1.8 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Build stage 1: Build TypeScript client
FROM node:20-alpine AS client-builder
WORKDIR /app/client
COPY client/package*.json ./
RUN npm ci --prefer-offline --no-audit
COPY client/ ./
RUN npm run build
# Build stage 2: Build Go binary
FROM golang:1.26-alpine AS go-builder
# Install git for version info and ca-certificates for HTTPS
RUN apk add --no-cache git ca-certificates
WORKDIR /app
# Allow Go to download required toolchain version if go.mod specifies newer
ENV GOTOOLCHAIN=auto
# Copy go mod files first for better caching
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Copy built client assets from previous stage (JS, CSS, and source maps)
COPY --from=client-builder /app/client/dist/ ./client/dist/
RUN mkdir -p internal/assets/client && \
cp client/dist/tinkerdown-client.browser.js internal/assets/client/ && \
cp client/dist/tinkerdown-client.browser.js.map internal/assets/client/ && \
cp client/dist/tinkerdown-client.browser.css internal/assets/client/ && \
cp client/dist/tinkerdown-client.browser.css.map internal/assets/client/
# Build with optimizations and version info
ARG VERSION=dev
ARG BUILD_TIME=unknown
RUN CGO_ENABLED=0 GOOS=linux go build \
-ldflags="-s -w -X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}" \
-o tinkerdown ./cmd/tinkerdown
# Runtime stage: Minimal Alpine image
FROM alpine:3.21
# Add ca-certificates for HTTPS requests and tzdata for timezone support
RUN apk add --no-cache ca-certificates tzdata
WORKDIR /app
# Copy the binary from builder
COPY --from=go-builder /app/tinkerdown /usr/local/bin/tinkerdown
# Create non-root user for security
RUN adduser -D -u 1000 tinkerdown && \
chown -R tinkerdown:tinkerdown /app
USER tinkerdown
EXPOSE 8080
ENTRYPOINT ["tinkerdown"]
CMD ["serve", "--host", "0.0.0.0", "/app"]