-
Notifications
You must be signed in to change notification settings - Fork 8
/
Dockerfile
44 lines (31 loc) · 1.19 KB
/
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
43
44
# First stage of multi-stage build: build the Go binary
FROM golang:alpine AS builder
# Install upx for compressing the binary and reducing the docker image size
RUN apk --no-cache add upx
# Create directory for build context
WORKDIR /build
# Copy everything inside the container
COPY go.mod .
COPY go.sum .
COPY *.go .
COPY VERSION .
COPY fingerprints ./fingerprints
# Download all dependencies
RUN go mod download
# Build the Go app. Set 'RUNNING_ENVIRONMENT' because e.g. the output directory needs to be different when the tool runs in docker
RUN CGO_ENABLED=0 go build -ldflags="-X main.RUNNING_ENVIRONMENT=docker -s -w" -trimpath -o subsnipe .
# Compress the binary using UPX
RUN upx --ultra-brute -qq subsnipe && upx -t subsnipe
# Second stage of multi-stage build: run the Go binary
FROM alpine:latest
# Install dig
# RUN apk --no-cache add bind-tools
WORKDIR /app
# Create the directory for the output.md file
RUN mkdir output
# Copy the Pre-built binary file from the previous stage
COPY --from=builder /build/subsnipe /app/subsnipe
# Copy the fingerprint files from the previous stage
COPY --from=builder /build/fingerprints /app/fingerprints
# Run the executable
ENTRYPOINT ["/app/subsnipe"]