-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (27 loc) · 843 Bytes
/
Copy pathDockerfile
File metadata and controls
40 lines (27 loc) · 843 Bytes
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
# Build stage
FROM golang:1.24-alpine AS builder
# Set working directory
WORKDIR /app
# Install git and other dependencies needed for building
RUN apk add --no-cache git ca-certificates tzdata
# Copy go mod files first for better caching
COPY go.mod go.sum ./
# Download dependencies
RUN go mod download
# Copy source code
COPY . .
# Build the server binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server cmd/server/main.go
# Runtime stage
FROM alpine:latest
# Install ca-certificates for HTTPS requests
RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/
# Copy configuration files
COPY config .
# Copy the binary from builder stage
COPY --from=builder /app/server .
# Expose port (Railway will provide PORT environment variable, but default to 8080)
EXPOSE 8080
# Run the server
CMD ["./server"]