init
This commit is contained in:
commit
ba1f43fd8e
35 changed files with 5926 additions and 0 deletions
61
Containerfile
Normal file
61
Containerfile
Normal file
|
@ -0,0 +1,61 @@
|
|||
FROM node:22-alpine AS frontend-builder
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY frontend /app
|
||||
|
||||
RUN npm install
|
||||
|
||||
RUN npm run build
|
||||
|
||||
# Multi-stage build for GoCheck application
|
||||
# Stage 1: Build the Go binary
|
||||
FROM golang:1.24-alpine AS builder
|
||||
|
||||
# Install git, ca-certificates, and build tools for CGO
|
||||
RUN apk add --no-cache git ca-certificates gcc musl-dev
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Copy go mod files
|
||||
COPY go.mod go.sum ./
|
||||
|
||||
# Download dependencies
|
||||
RUN go mod download
|
||||
|
||||
# Copy source code
|
||||
COPY . .
|
||||
|
||||
COPY --from=frontend-builder /app/dist /app/frontend/dist
|
||||
|
||||
# Build the binary with embedded static files
|
||||
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o gocheck .
|
||||
|
||||
# Stage 2: Create minimal runtime container
|
||||
FROM alpine:latest
|
||||
|
||||
# Install runtime dependencies for SQLite
|
||||
RUN apk add --no-cache ca-certificates sqlite
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup -g 1001 -S gocheck && \
|
||||
adduser -S -D -H -h /app -s /sbin/nologin -G gocheck -g gocheck -u 1001 gocheck
|
||||
|
||||
# Copy the binary from builder stage
|
||||
COPY --from=builder /app/gocheck /app/gocheck
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Change ownership to non-root user
|
||||
RUN chown -R gocheck:gocheck /app
|
||||
|
||||
# Switch to non-root user
|
||||
USER gocheck
|
||||
|
||||
# Expose default port (can be overridden via PORT env var)
|
||||
EXPOSE 8080
|
||||
|
||||
# Run the binary
|
||||
ENTRYPOINT ["/app/gocheck"]
|
Loading…
Add table
Add a link
Reference in a new issue