44 lines
805 B
Docker
44 lines
805 B
Docker
# Build stage
|
|
FROM golang:1.25-bookworm AS builder
|
|
|
|
WORKDIR /app
|
|
|
|
# Install dependencies including libenet-dev from Debian repos
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
git \
|
|
gcc \
|
|
pkg-config \
|
|
libenet-dev \
|
|
sqlite3 \
|
|
libsqlite3-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Copy go mod and sum files
|
|
COPY go.mod go.sum ./
|
|
|
|
# Download dependencies
|
|
RUN go mod download
|
|
|
|
COPY ./*.go .
|
|
|
|
# Enable CGO for go-sqlite3 and go-enet
|
|
ENV CGO_ENABLED=1
|
|
|
|
RUN go build -o main .
|
|
|
|
# Runtime stage
|
|
FROM debian:bookworm-slim
|
|
|
|
WORKDIR /app
|
|
|
|
# Install runtime dependencies
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libenet7 \
|
|
ca-certificates \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
COPY --from=builder /app/main .
|
|
|
|
EXPOSE 8095
|
|
|
|
CMD ["./main"]
|