change to golang

This commit is contained in:
2025-12-10 14:27:04 +11:00
parent 53852868aa
commit 64f9da1549
18 changed files with 612 additions and 455 deletions

View File

@@ -1,21 +1,24 @@
FROM python:3.12-slim
# Build stage
FROM golang:1.25-bookworm AS build
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
COPY main.go .
RUN ln -sf /usr/local/bin/python3 /usr/bin/python3
# Build a static-ish binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o passgen main.go
# Runtime stage: minimal image with just the binary + wordlist
FROM debian:13-slim
WORKDIR /app
COPY . /app/
RUN mkdir -p /app/cgi-bin \
&& cp /app/*.py /app/*.cgi /app/cgi-bin/ \
&& cp /app/words.txt /app/cgi-bin/ \
&& cp /app/*.html /app/cgi-bin/
# Copy binary and wordlist
COPY --from=build /src/passgen /app/passgen
COPY words.txt /app/words.txt
RUN chmod +x /app/index.cgi
RUN chmod +x /app/cgi-bin/*.py /app/cgi-bin/*.cgi || true
ENV WORDLIST=/app/words.txt
ENV PORT=8000
EXPOSE 8000
CMD ["python", "-m", "http.server", "8000", "--cgi"]
CMD ["/app/passgen"]