-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
65 lines (45 loc) · 1.62 KB
/
Dockerfile
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
# Use Go 1.23 bookworm as base image
FROM golang:1.23-bookworm AS base
# Development stage
# =============================================================================
# Create a development stage based on the "base" image
FROM base AS development
# Change the working directory to /app
WORKDIR /app
RUN git config --global --add safe.directory /app
RUN apt-get update && apt-get install libaom-dev -y --no-install-recommends
# Install the air CLI for auto-reloading
RUN go install github.com/air-verse/air@latest
# Copy the go.mod and go.sum files to the /app directory
COPY go.mod go.sum ./
# Install dependencies
RUN go mod download
# Start air for live reloading
CMD ["air"]
# Builder stage
# =============================================================================
# Create a builder stage based on the "base" image
FROM base AS builder
# Move to working directory /build
WORKDIR /build
RUN apt-get update && apt-get install libaom-dev -y --no-install-recommends
# Copy the go.mod and go.sum files to the /build directory
COPY go.mod go.sum ./
# Install dependencies
RUN go mod download
# Copy the entire source code into the container
COPY . .
# Build the application
RUN CGO_ENABLED=0 go build -o go-social-login
# Production stage
# =============================================================================
# Create a production stage to run the application binary
FROM scratch AS production
# Move to working directory /prod
WORKDIR /prod
# Copy binary from builder stage
COPY --from=builder /build/demo-app ./
# Document the port that may need to be published
EXPOSE 8000
# Start the application
CMD ["/prod/demo-app"]