2025-02-02 19:35:13 +01:00
|
|
|
# =========================================
|
2026-02-17 22:14:04 +01:00
|
|
|
# STAGE 1 -- Build Fail2Ban-UI Binary
|
2025-02-02 19:35:13 +01:00
|
|
|
# =========================================
|
2026-02-17 22:14:04 +01:00
|
|
|
FROM golang:1.25.7 AS builder
|
2025-02-02 19:35:13 +01:00
|
|
|
|
|
|
|
|
WORKDIR /app
|
|
|
|
|
|
2026-02-17 22:14:04 +01:00
|
|
|
# Copy module files and download dependencies
|
2025-02-02 19:35:13 +01:00
|
|
|
COPY go.mod go.sum ./
|
|
|
|
|
RUN go mod download
|
|
|
|
|
|
2026-02-17 22:14:04 +01:00
|
|
|
# Copy application source code to buildcontainer
|
2025-02-02 19:35:13 +01:00
|
|
|
COPY . .
|
|
|
|
|
|
2026-02-17 22:14:04 +01:00
|
|
|
# Build Go application
|
2025-02-02 19:35:13 +01:00
|
|
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o fail2ban-ui ./cmd/server/main.go
|
|
|
|
|
|
|
|
|
|
# ===================================
|
2026-02-17 22:14:04 +01:00
|
|
|
# STAGE 2 -- Standalone UI Version
|
2025-02-02 19:35:13 +01:00
|
|
|
# ===================================
|
2026-02-17 23:30:44 +01:00
|
|
|
FROM alpine:3.23 AS standalone-ui
|
2025-02-02 19:35:13 +01:00
|
|
|
|
|
|
|
|
# Install required container dependencies
|
2026-02-17 23:30:44 +01:00
|
|
|
RUN set -eux; \
|
|
|
|
|
apk update; \
|
|
|
|
|
apk upgrade --no-cache; \
|
|
|
|
|
apk add --no-cache \
|
|
|
|
|
bash curl wget whois tzdata jq ca-certificates htop fail2ban geoip openssh-client; \
|
|
|
|
|
adduser -D -u 1000 -G root fail2ban
|
2025-02-02 19:35:13 +01:00
|
|
|
|
2025-11-13 22:29:13 +01:00
|
|
|
RUN mkdir -p /app /config /config/.ssh \
|
2025-02-02 19:35:13 +01:00
|
|
|
/etc/fail2ban/jail.d \
|
|
|
|
|
/etc/fail2ban/filter.d \
|
|
|
|
|
/etc/fail2ban/action.d \
|
|
|
|
|
/var/run/fail2ban \
|
|
|
|
|
/usr/share/GeoIP \
|
|
|
|
|
&& touch /etc/fail2ban/jail.local \
|
|
|
|
|
&& chown -R fail2ban:0 /app /config /etc/fail2ban /var/run/fail2ban
|
|
|
|
|
|
2026-02-17 22:14:04 +01:00
|
|
|
# Set working directory and volume
|
2025-02-02 19:35:13 +01:00
|
|
|
WORKDIR /config
|
2026-02-17 22:14:04 +01:00
|
|
|
VOLUME ["/config"]
|
|
|
|
|
|
|
|
|
|
ENV CONTAINER=true
|
2025-02-02 19:35:13 +01:00
|
|
|
|
2026-02-17 22:14:04 +01:00
|
|
|
# Copy Fail2Ban-UI binary and templates from the build stage
|
2025-02-02 19:35:13 +01:00
|
|
|
COPY --from=builder /app/fail2ban-ui /app/fail2ban-ui
|
|
|
|
|
COPY --from=builder /app/pkg/web/templates /app/templates
|
2025-02-26 20:40:31 +01:00
|
|
|
COPY --from=builder /app/internal/locales /app/locales
|
2025-11-18 00:10:37 +01:00
|
|
|
COPY --from=builder /app/pkg/web/static /app/static
|
2026-02-17 22:14:04 +01:00
|
|
|
RUN chown fail2ban:0 /app/fail2ban-ui && chmod +x /app/fail2ban-ui
|
2025-02-02 19:35:13 +01:00
|
|
|
|
|
|
|
|
EXPOSE 8080
|
|
|
|
|
CMD ["/app/fail2ban-ui"]
|