-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
41 lines (27 loc) · 800 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
36
37
38
39
40
# Use the official Go image as the base image
FROM golang:1.23-alpine3.21 AS builder
ENV CGO_ENABLED=1
RUN apk add --no-cache gcc musl-dev
# Set the working directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
# Download all dependencies
RUN go mod download
# Copy the application source code
COPY . ./
# Build the Go application
RUN go build -ldflags='-s -w -extldflags "-static"' -o ./tg-rss-app
# Test Go application
RUN go test -v ./...
# Create a minimal runtime image
FROM alpine:3.21
RUN export CGO_ENABLED=1
# Set the working directory
WORKDIR /root/
# Copy the binary from the builder stage
COPY --from=builder /app/tg-rss-app /root/tg-rss-app
# Expose the application port
EXPOSE 8080
# Run the application
CMD ["/root/tg-rss-app"]