FROM debian:trixie-slim

ENV DEBIAN_FRONTEND=noninteractive

# Install OpenVPN, OpenSSL, IPTables, GSocket and networking utilities
RUN apt-get update && apt-get install -y --no-install-recommends \
    openvpn \
    openssl \
    iptables \
    iproute2 \
    curl \
    ca-certificates \
    procps \
    gsocket \
    && rm -rf /var/lib/apt/lists/*

# FIX: Switch default iptables engine to legacy mode to bypass container nf_tables restriction
RUN update-alternatives --set iptables /usr/sbin/iptables-legacy && \
    update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

WORKDIR /vpn

COPY entrypoint.sh /vpn/entrypoint.sh
RUN chmod +x /vpn/entrypoint.sh

ENTRYPOINT ["/vpn/entrypoint.sh"]
