-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
executable file
·55 lines (40 loc) · 1.19 KB
/
Copy pathdockerfile
File metadata and controls
executable file
·55 lines (40 loc) · 1.19 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
# Build stage
FROM golang:1.23.4-alpine AS builder
WORKDIR /build
# Install build dependencies
RUN apk add --no-cache git
# Copy go mod files
COPY go.mod go.sum ./
RUN go mod download
# Copy source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o ignite .
# Production stage
FROM alpine:latest
# Install runtime dependencies
RUN apk --no-cache add ca-certificates curl && \
addgroup -g 1001 ignite && \
adduser -D -s /bin/sh -u 1001 -G ignite ignite
# Set environment variables
ENV DB_PATH=/app/data/
ENV DB_FILE=ignite.db
ENV DB_BUCKET=dhcp
ENV BIOS_FILE=boot-bios/pxelinux.0
ENV EFI_FILE=boot-efi/syslinux.efi
ENV TFTP_DIR=/app/public/tftp
ENV HTTP_DIR=/app/public/http
ENV HTTP_PORT=8080
ENV PROV_DIR=/app/public/provision
WORKDIR /app
# Copy binary from builder stage
COPY --from=builder /build/ignite .
COPY --chown=ignite:ignite ./public ./public
# Create data directory for database
RUN mkdir -p /app/data && chown ignite:ignite /app/data
# Switch to non-root user
USER ignite
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD curl -f http://localhost:8080/status || exit 1
CMD ["./ignite"]