Files
palace/Dockerfile.backend
2025-07-19 00:55:13 +02:00

37 lines
708 B
Docker

# Backend API server Dockerfile
FROM golang:1.21-alpine AS builder
WORKDIR /app
# Install git
RUN apk add --no-cache git
# Clone the repository
RUN git clone https://git.raphaelforment.fr/BuboBubo/palace.git .
# Build the Go application
WORKDIR /app/server
RUN go mod tidy
RUN CGO_ENABLED=1 GOOS=linux go build -a -installsuffix cgo -o main .
# Production stage
FROM alpine:latest
# Install sqlite3 for CGO
RUN apk --no-cache add ca-certificates sqlite
WORKDIR /root/
# Copy the binary
COPY --from=builder /app/server/main .
# Create data directory for SQLite
RUN mkdir -p /data
# Expose port
EXPOSE 3001
# Set environment variable for database location
ENV DB_PATH=/data/palace.db
CMD ["./main"]