33 lines
859 B
Text
33 lines
859 B
Text
# use a minimal base image
|
|
FROM golang:1.23 AS builder
|
|
|
|
# set the working directory in the container
|
|
WORKDIR /app
|
|
|
|
# copy the go project files
|
|
COPY . .
|
|
|
|
# build the go server
|
|
RUN go mod tidy && CGO_ENABLED=0 go build -o codex-server
|
|
|
|
# create a smaller final image
|
|
FROM alpine:latest
|
|
|
|
WORKDIR /app
|
|
|
|
# copy the built binary from the builder stage
|
|
COPY --from=builder /app/codex-server .
|
|
COPY --from=builder /app/static /app/static
|
|
COPY --from=builder /app/templates /app/templates
|
|
COPY --from=builder /app/blog-posts /app/blog-posts
|
|
COPY --from=builder /app/documentation /app/documentation
|
|
|
|
# set a non-root user for security
|
|
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
|
|
USER appuser
|
|
|
|
# expose the port (match your go server's listening port)
|
|
EXPOSE 61594
|
|
|
|
# run the go server
|
|
ENTRYPOINT ["./codex-server"]
|