31 lines
979 B
Docker
31 lines
979 B
Docker
FROM debian:latest
|
|
ARG PORT
|
|
|
|
# Install deps
|
|
RUN apt-get update && apt-get install --yes \
|
|
curl apache2 wireguard-tools sudo \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Create dirs and temp files
|
|
RUN mkdir /usr/lib/wgapi /var/log/wgapi
|
|
RUN chown -R www-data:www-data /usr/lib/wgapi /var/log/wgapi
|
|
|
|
# Configure apache
|
|
RUN a2enmod cgi rewrite
|
|
RUN sed -i "s/^Listen 80$/Listen ${PORT}/" /etc/apache2/ports.conf
|
|
RUN sed -i -e "s/^<VirtualHost \*:80>$/<VirtualHost *:${PORT}>/" \
|
|
-e "s|DocumentRoot .*$|DocumentRoot /usr/lib/cgi-bin\n\tSetHandler cgi-script\n\tOptions +ExecCGI|" \
|
|
/etc/apache2/sites-available/000-default.conf
|
|
|
|
# Allow http user to run these binaries as root with sudo
|
|
RUN echo "www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/wg, /usr/bin/[, /usr/bin/tee" \
|
|
| sudo EDITOR='tee -a' visudo
|
|
|
|
# Copy over cgi and libs
|
|
COPY fed.cgi /usr/lib/cgi-bin/index.cgi
|
|
# TODO: Copy only needed libs
|
|
COPY lib/ /usr/lib/wgapi/
|
|
|
|
# Run time!
|
|
EXPOSE ${PORT}
|
|
CMD ["apachectl", "-D", "FOREGROUND"] |