-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile
More file actions
50 lines (35 loc) · 1.2 KB
/
Dockerfile
File metadata and controls
50 lines (35 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
FROM golang:1.23-alpine AS builder
WORKDIR /app
# Install git and ca-certificates for building
RUN apk add --no-cache git ca-certificates
# Diagnostic: Print Go version in build environment
RUN go version
# Copy go mod and sum files
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the binary
ARG VERSION=docker
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X main.version=${VERSION}" -o github-copilot-svcs ./cmd/github-copilot-svcs
# Final stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates tzdata wget
# Create non-root user
RUN addgroup -S appgroup && adduser -S appuser -G appgroup
# Switch to non-root user
USER appuser
WORKDIR /home/appuser/
# Copy the binary from builder
COPY --from=builder /app/github-copilot-svcs .
# Create config directory for non-root user
RUN mkdir -p /home/appuser/.local/share/github-copilot-svcs
# Expose the default port
EXPOSE 8081
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:8081/health || exit 1
# Run the binary
CMD ["./github-copilot-svcs", "start"]