| # Use a lightweight Python base image | |
| FROM python:3.11-slim | |
| # Set the working directory | |
| WORKDIR /app | |
| # Install the pvpn library, FastAPI, Uvicorn, and Supervisord | |
| # Running as root for this step. | |
| RUN apt-get update && \ | |
| apt-get install -y supervisor && \ | |
| pip install pvpn fastapi uvicorn python-multipart && \ | |
| apt-get clean && rm -rf /var/lib/apt/lists/* | |
| # Ensure the working directory is writeable (though it is by default for root) | |
| # This addresses the user's explicit request. | |
| RUN chmod -R 777 /app | |
| # The container will run as the default root user, which allows binding to | |
| # privileged ports 500 and 4500 without needing setcap. | |
| # Copy the server scripts and supervisord config | |
| # No need for --chown as we are running as root | |
| COPY vpn_server.py web_ui.py supervisord.conf . | |
| # Expose the standard IKEv2 ports (UDP 500 and 4500) | |
| EXPOSE 500/udp | |
| EXPOSE 4500/udp | |
| # Expose the Web UI port (TCP 8000) | |
| EXPOSE 8000/tcp | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Command to run Supervisord, which manages both the IKEv2 server and the Web UI | |
| CMD ["/usr/bin/supervisord", "-c", "supervisord.conf"] | |