# 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 # 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"]