README.md
Rendering markdown...
# Use the official Go image as the base image
FROM golang:1.21 AS builder
# Set the working directory
WORKDIR /app
# Copy go mod files
COPY go.mod go.sum* ./
# Download dependencies
RUN go mod download
# Copy the source code
COPY . .
# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o main .
# Use Ubuntu as the base image for the final stage
FROM ubuntu:22.04
# Install Python and pip
RUN apt-get update && apt-get install -y \
python3 \
python3-pip \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user
RUN groupadd -g 1001 appuser && \
useradd -u 1001 -g appuser -m -s /bin/bash appuser
# Set the working directory
WORKDIR /app
# Copy the binary from the builder stage
COPY --from=builder /app/main .
# Copy Python testing files
COPY requirements.txt test_exploit.py ./
# Install Python dependencies
RUN pip3 install --no-cache-dir -r requirements.txt
# Create directories for uploads and extracted files
RUN mkdir -p uploads extracted && \
chown -R appuser:appuser /app
# Switch to non-root user
USER appuser
# Expose port 8080
EXPOSE 8080
# Run the application
CMD ["./main"]