wagon/back/admin.Dockerfile

34 lines
1.2 KiB
Plaintext
Raw Normal View History

2022-09-14 09:21:52 -06:00
FROM debian:latest
ARG PORT
2022-09-14 09:21:52 -06:00
# Install deps
RUN apt-get update && apt-get install --yes \
2022-11-07 13:10:59 -07:00
sudo curl apache2 openssl wireguard-tools dnsutils ipv6calc jq \
2022-09-14 09:21:52 -06:00
&& rm -rf /var/lib/apt/lists/*
2022-09-14 18:50:21 -06:00
# Create dirs and temp files
RUN mkdir /usr/lib/wagon /var/log/wagon /var/local/wagon
RUN touch /var/local/wagon/tokens
RUN chown -R www-data:www-data /usr/lib/wagon /var/log/wagon /var/local/wagon
2022-09-14 09:21:52 -06:00
# Configure apache
RUN a2enmod cgi rewrite
2022-11-07 15:34:27 -07:00
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|" \
2022-09-14 09:21:52 -06:00
/etc/apache2/sites-available/000-default.conf
2022-11-07 10:49:18 -07:00
# Allow http user to run these binaries as root with sudo
2022-10-21 09:07:14 -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, /bin/chgrp" \
2022-11-07 10:49:18 -07:00
| sudo EDITOR='tee -a' visudo
2022-09-14 09:21:52 -06:00
2022-09-14 18:50:21 -06:00
# Copy over CGIs and libs
2022-11-06 18:38:06 -07:00
COPY admin_peer.cgi /usr/lib/cgi-bin/peer
COPY admin_user.cgi /usr/lib/cgi-bin/user
2022-09-14 18:50:21 -06:00
# TODO: Copy only needed libs
COPY lib/ /usr/lib/wagon/
2022-09-14 09:21:52 -06:00
# Run time!
2022-11-07 15:34:27 -07:00
EXPOSE ${PORT}
2022-09-14 09:21:52 -06:00
CMD ["apachectl", "-D", "FOREGROUND"]