| # Use a lightweight Python base image | |
| FROM python:3.11-slim | |
| # Set the working directory | |
| WORKDIR /app | |
| # Install the pvpn library | |
| RUN pip install pvpn | |
| RUN chmod -R 777 /app | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| COPY --chown=user . /app | |
| # Expose the standard IKEv2 ports (UDP 500 and 4500) | |
| # Note: The 'pvpn' server runs as root inside the container to bind to these ports, | |
| # but the container is run by a non-root user on the host. | |
| EXPOSE 500/udp | |
| EXPOSE 4500/udp | |
| # Command to run the server script | |
| # We use 'python3' instead of 'sudo python3' because the container runs as root by default, | |
| # which is necessary to bind to the privileged ports 500 and 4500. | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] |