-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
56 lines (42 loc) · 1.13 KB
/
Dockerfile
File metadata and controls
56 lines (42 loc) · 1.13 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
# Stage 1: Build the Go application
FROM ubuntu:latest AS builder
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies
RUN apt-get update && apt-get install -y \
wget \
curl \
git \
build-essential \
python3 \
python3-pip \
python3-venv \
golang \
&& apt-get clean
# Set Go environment variables
ENV GOPATH=/go
ENV PATH=$GOPATH/bin:/usr/local/go/bin:$PATH
# Set the working directory
WORKDIR /app
# Copy go.mod and go.sum to download dependencies
COPY go.mod go.sum ./
RUN go mod download
# Copy the rest of the application code
COPY . .
# Build the application as a static binary
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o gin-app .
# Stage 2: Create a runtime image
FROM python:3.11-alpine
# Install additional dependencies (if required)
RUN apk add --no-cache \
py3-pip \
py3-setuptools
# Set environment variables
ENV GIN_MODE=release
# Set the working directory
WORKDIR /root/
# Copy the Go binary from the builder stage
COPY --from=builder /app/gin-app .
# Expose the port the application will run on
EXPOSE 8080
# Command to run the application
CMD ["./gin-app"]