-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
52 lines (37 loc) · 1.51 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
45
46
47
48
49
50
51
# Use an official Golang image to build the application
FROM golang:1.20 as builder
# Set environment variables for Alpine compatibility
ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64
# Set the working directory
WORKDIR /app
# Copy the Go modules and source code
COPY go.mod ./
RUN go mod download
COPY . .
# Build the Go application
RUN GOOS=linux GOARCH=amd64 go build -o go-dnsbrute main.go
# Use a minimal base image for the final container
FROM alpine:latest
# LABELS
LABEL org.opencontainers.image.title="go-dnsbrute" \
org.opencontainers.image.description="A DNS brute-forcing tool built in Go for security testing purposes." \
org.opencontainers.image.version="0.1" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.url="docker.io/raj77in/go-dnsbrute" \
org.opencontainers.image.source="https://github.com/raj77in/go-dnsbrute" \
org.opencontainers.image.revision="0.1" \
org.opencontainers.image.created="2024-11-30" \
org.opencontainers.image.authors="Amit Agarwal" \
org.opencontainers.image.documentation="https://github.com/raj77in/go-dnsbrute"
# Create a non-root user named 'go'
RUN adduser -D -u 1001 go
# Set the working directory in the container
WORKDIR /app
# Change ownership of the working directory and binary to the 'go' user
RUN chown -R go:go /app
# Switch to the 'go' user
USER go
# Copy the compiled binary from the builder stage
COPY --from=builder /app/go-dnsbrute .
# Command to run your application
ENTRYPOINT ["/app/go-dnsbrute"]