switch to golang wrapper for enet

This commit is contained in:
Travis Shears 2026-04-13 13:50:21 +02:00
parent 4420b4e061
commit ee3b8d3490
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
10 changed files with 188 additions and 194 deletions

View file

@ -1,14 +1,44 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /build
COPY Backend.csproj .
RUN dotnet restore
COPY . .
RUN dotnet build -c Release
# Build stage
FROM golang:1.25-bookworm AS builder
FROM mcr.microsoft.com/dotnet/runtime:10.0
WORKDIR /app
COPY --from=build /build/bin/Release/net10.0 .
ENV ENET_HOST=0.0.0.0
ENV ENET_PORT=7777
EXPOSE 7777/udp
ENTRYPOINT ["./Backend"]
# 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"]