-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdockerfile
More file actions
66 lines (48 loc) · 1.52 KB
/
Copy pathdockerfile
File metadata and controls
66 lines (48 loc) · 1.52 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Build Stage
FROM golang:1.23.1-alpine AS builder
WORKDIR /app
# Install build dependencies
RUN apk add --no-cache git protoc protobuf-dev make
# Install protoc plugins for Go
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# Set PATH to include Go binaries
ENV PATH="$PATH:/root/go/bin"
# Copy go mod files first for better layer caching
COPY go.mod go.sum ./
RUN go mod download && go get -u google.golang.org/grpc && go get -u google.golang.org/protobuf
# Copy source code
COPY . .
# Generate protobuf files
RUN make gen-proto
# Generate swagger documentation
RUN go install github.com/swaggo/swag/cmd/swag@latest
RUN make gen-docs
# Build the application
RUN go build -o thinkink-server ./cmd/main.go
# Runtime Stage
FROM alpine:latest
WORKDIR /app
# Install runtime dependencies
RUN apk add --no-cache ca-certificates tzdata
# Copy binary from builder
COPY --from=builder /app/thinkink-server /app/thinkink-server
# Copy generated files
COPY --from=builder /app/docs /app/docs
COPY --from=builder /app/proto-gen /app/proto-gen
# Create directory for uploaded files
RUN mkdir -p /app/uploads
# Default environment variables - these can be overridden at runtime
ENV PORT=8080 \
GRPC_PORT=50051 \
APP_ENV=production \
DB_HOST=postgres \
DB_USER=postgres \
DB_PASSWORD=postgres \
DB_NAME=postgres \
DB_PORT=5432 \
DB_SSL_MODE=disable
# Expose ports
EXPOSE 8080 50051
# Command to run
ENTRYPOINT ["/app/thinkink-server"]