2022-09-06 20:57:41 -06:00
|
|
|
FROM debian:latest
|
2022-09-10 10:54:30 -06:00
|
|
|
|
|
|
|
# Change these
|
2022-09-14 14:44:00 -06:00
|
|
|
ENV LISTEN_PORT=4442
|
2022-09-07 16:57:52 -06:00
|
|
|
ENV ADMIN_EMAIL='me@example.com'
|
2022-11-07 10:30:31 -07:00
|
|
|
ENV SERVER_NAME='wg-test-dashboard.ksn.gf4'
|
2022-09-10 10:54:30 -06:00
|
|
|
|
|
|
|
# Install deps
|
2022-09-07 16:22:19 -06:00
|
|
|
RUN apt-get update && apt-get install --yes \
|
2022-09-10 09:59:27 -06:00
|
|
|
sudo curl apache2 openssl wireguard-tools dnsutils ipv6calc jq \
|
2022-09-07 16:22:19 -06:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2022-09-10 10:54:30 -06:00
|
|
|
|
2022-09-14 18:50:21 -06:00
|
|
|
# Create dirs and temp files
|
2022-11-06 17:41:55 -07:00
|
|
|
RUN mkdir /usr/lib/wgapi /var/log/wgapi
|
2022-09-14 18:50:21 -06:00
|
|
|
RUN touch /var/local/wgapi_tokens /var/log/wgapi/wgapi.log
|
2022-11-06 17:41:55 -07:00
|
|
|
RUN chown -R www-data:www-data /usr/lib/wgapi /var/log/wgapi /var/local/wgapi_tokens
|
2022-09-10 19:01:36 -06:00
|
|
|
|
2022-09-10 10:54:30 -06:00
|
|
|
# Configure apache
|
2022-09-06 20:57:41 -06:00
|
|
|
RUN a2enmod cgi rewrite
|
2022-09-07 16:57:52 -06:00
|
|
|
RUN sed -i "s/^Listen 80$/Listen ${LISTEN_PORT}/" \
|
|
|
|
/etc/apache2/ports.conf
|
2022-11-07 10:30:31 -07:00
|
|
|
RUN sed -i -e "s/^<VirtualHost \*:80>$/<VirtualHost *:${LISTEN_PORT}>/" \
|
2022-11-07 11:17:48 -07:00
|
|
|
-e "s|DocumentRoot .*$|DocumentRoot /usr/lib/cgi-bin/|" \
|
2022-11-07 10:30:31 -07:00
|
|
|
-e "s/ServerAdmin .*$/ServerAdmin ${ADMIN_EMAIL}/" \
|
|
|
|
-e "s/#ServerName .*$/ServerName ${SERVER_NAME}/" \
|
2022-11-07 10:49:18 -07:00
|
|
|
-e 's|#Include conf-available/serve-cgi-bin.conf|Include conf-available/serve-cgi-bin.conf|' \
|
2022-09-07 16:57:52 -06:00
|
|
|
/etc/apache2/sites-available/000-default.conf
|
2022-09-10 10:54:30 -06:00
|
|
|
|
2022-11-07 10:30:31 -07:00
|
|
|
# Allow http user to run these binaries as root with sudo
|
2022-09-10 12:20:55 -06:00
|
|
|
RUN echo "www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/wg, /usr/bin/openssl, /usr/bin/[, /usr/bin/tee, /bin/cat, /bin/mkdir, /bin/rm, /bin/chmod" \
|
2022-11-07 10:30:31 -07:00
|
|
|
| sudo EDITOR='tee -a' visudo
|
2022-09-10 10:54:30 -06:00
|
|
|
|
2022-09-14 18:50:21 -06:00
|
|
|
# Copy over cgi and libs
|
2022-11-07 10:30:31 -07:00
|
|
|
COPY dashboard.cgi /usr/lib/cgi-bin/index
|
2022-11-06 18:13:52 -07:00
|
|
|
COPY dashboard_ssl.cgi /usr/lib/cgi-bin/ssl
|
2022-11-06 17:09:55 -07:00
|
|
|
# TODO: Copy only needed libs
|
2022-09-14 18:50:21 -06:00
|
|
|
COPY lib/ /usr/lib/wgapi/
|
2022-09-10 10:54:30 -06:00
|
|
|
|
|
|
|
# Run time!
|
2022-09-07 16:57:52 -06:00
|
|
|
EXPOSE ${LISTEN_PORT}
|
2022-09-12 10:09:36 -06:00
|
|
|
CMD ["apachectl", "-D", "FOREGROUND"]
|