this repo has no description
at main 876 B view raw
1# Server Dockerfile for Go application 2 3# Build stage 4FROM golang:1.21-alpine AS builder 5 6WORKDIR /app 7 8# Install build dependencies 9RUN apk add --no-cache gcc musl-dev 10 11# Copy go mod files 12COPY go.mod go.sum ./ 13 14# Download dependencies 15RUN go mod download 16 17# Copy source code 18COPY server/ ./server/ 19COPY db/ ./db/ 20 21# Create output directory 22RUN mkdir -p /app/bin 23 24# Build the application 25RUN CGO_ENABLED=1 go build -o /app/bin/server-app ./server/main.go 26 27# Final stage 28FROM alpine:latest 29 30WORKDIR /app 31 32# Install runtime dependencies 33RUN apk add --no-cache ca-certificates 34 35# Copy binary from builder stage 36COPY --from=builder /app/bin/server-app /app/ 37 38# Copy SQLite extension 39COPY --from=builder /app/db/crsqlite.so /app/db/crsqlite.so 40 41# Create directory for room databases 42RUN mkdir -p /app/rooms 43 44# Expose port 45EXPOSE 8080 46 47# Run the application 48CMD ["/app/server-app"]