-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
35 lines (24 loc) · 799 Bytes
/
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
# Stage 1: Build the Go application
FROM golang:1.20-alpine AS builder
# Set the working directory inside the container
WORKDIR /app
# Copy the go.mod and go.sum files for dependency resolution
COPY go.mod go.sum ./
# Download and cache dependencies
RUN go mod download
# Copy the rest of the application code
COPY SMS-Server.go .
# Build the Go application
RUN go build -o PostApi-server .
# Stage 2: Create a lightweight runtime image
FROM alpine:latest
# Set the working directory inside the runtime container
WORKDIR /app
# Copy the built binary from the builder stage
COPY --from=builder /app/server /app/server
# Copy the config file into the container
COPY config.json /app/config.json
# Expose the application port
EXPOSE 8080
# Command to run the binary
CMD ["./PostApi-server"]