-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
42 lines (30 loc) · 1009 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
41
42
# First stage: Build the Go application
FROM golang:1.23-alpine AS builder
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy go.mod and go.sum files
COPY go.mod go.sum ./
ENV GOPATH=/opt/geoipupdate
# Install dependencies
RUN apk add --update git
RUN go mod download
RUN go install github.com/maxmind/geoipupdate/v7/cmd/geoipupdate@latest
# Copy the source code into the container
COPY . .
# Build the Go app
RUN go build -o service-detection .
# Second stage: Create a smaller image with just the binary
FROM alpine:latest
# Set the Current Working Directory inside the container
WORKDIR /root/
# Copy the binary from the builder stage
COPY --from=builder /app/service-detection .
COPY --from=builder /opt/geoipupdate/bin/geoipupdate /usr/bin/
# Expose ports for DNS (53) and HTTP (80)
EXPOSE 53/udp
EXPOSE 80
COPY docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
# Command to run the executable
CMD ["./service-detection"]