Create Dockerfile
Browse files- Dockerfile +39 -0
Dockerfile
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Stage 1: Build the application
|
2 |
+
FROM golang:1.20 AS builder
|
3 |
+
|
4 |
+
# Set the working directory inside the container
|
5 |
+
WORKDIR /app
|
6 |
+
|
7 |
+
# Copy go.mod and go.sum to download dependencies
|
8 |
+
COPY go.mod go.sum ./
|
9 |
+
RUN go mod download
|
10 |
+
|
11 |
+
# Copy the rest of the application code
|
12 |
+
COPY . .
|
13 |
+
|
14 |
+
# Build the application binary
|
15 |
+
RUN go build -o go_jackett main.go
|
16 |
+
|
17 |
+
# Stage 2: Create a minimal runtime container
|
18 |
+
FROM debian:bullseye-slim
|
19 |
+
|
20 |
+
# Set the working directory
|
21 |
+
WORKDIR /app
|
22 |
+
|
23 |
+
# Install essential packages (for running the app)
|
24 |
+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
|
25 |
+
|
26 |
+
# Copy the binary and required directories from the builder stage
|
27 |
+
COPY --from=builder /app/go_jackett /app/
|
28 |
+
COPY --from=builder /app/.env /app/
|
29 |
+
COPY --from=builder /app/persistence /app/persistence
|
30 |
+
COPY --from=builder /app/temp /app/temp
|
31 |
+
|
32 |
+
# Set the default environment variable (optional, can be overridden)
|
33 |
+
ENV PORT=3000
|
34 |
+
|
35 |
+
# Expose the application port
|
36 |
+
EXPOSE 3000
|
37 |
+
|
38 |
+
# Start the application
|
39 |
+
CMD ["./go_jackett"]
|