Dockerfile raw

   1  # Build stage
   2  FROM golang:1.22-alpine AS builder
   3  
   4  WORKDIR /app
   5  
   6  # Install git for go modules
   7  RUN apk add --no-cache git
   8  
   9  # Copy go mod files
  10  COPY go.mod go.sum ./
  11  RUN go mod download
  12  
  13  # Copy source code
  14  COPY . .
  15  
  16  # Build the binary
  17  RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o nostr-oauth2-server ./cmd/nostr-oauth2-server
  18  
  19  # Runtime stage
  20  FROM alpine:3.19
  21  
  22  RUN apk --no-cache add ca-certificates
  23  
  24  WORKDIR /app
  25  
  26  # Copy binary from builder
  27  COPY --from=builder /app/nostr-oauth2-server .
  28  
  29  # Copy default config
  30  COPY config.example.yaml /app/config.yaml
  31  
  32  # Expose port
  33  EXPOSE 8080
  34  
  35  # Run the server
  36  ENTRYPOINT ["./nostr-oauth2-server"]
  37  CMD ["-config", "/app/config.yaml"]
  38