wagon/back/fed.Dockerfile

32 lines
1008 B
Plaintext
Raw Normal View History

2022-09-14 14:44:00 -06:00
FROM debian:latest
2022-11-27 16:00:43 -07:00
ARG PORT
2022-09-14 14:44:00 -06:00
# Install deps
2022-11-27 16:00:43 -07:00
RUN apt-get update && apt-get install --yes \
2023-12-02 18:52:42 -07:00
curl apache2 wireguard-tools sudo iproute2 \
2022-09-14 14:44:00 -06:00
&& rm -rf /var/lib/apt/lists/*
2022-11-27 16:00:43 -07:00
# Create dirs and temp files
RUN mkdir /usr/lib/wagon /var/log/wagon
RUN chown -R www-data:www-data /usr/lib/wagon /var/log/wagon
2022-11-27 16:00:43 -07:00
2022-09-14 14:44:00 -06:00
# Configure apache
RUN a2enmod cgi rewrite
2022-11-27 16:00:43 -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 14:44:00 -06:00
/etc/apache2/sites-available/000-default.conf
2022-11-27 16:00:43 -07:00
# Allow http user to run these binaries as root with sudo
RUN echo "www-data ALL=(ALL:ALL) NOPASSWD: /usr/bin/wg, /usr/bin/wg-quick, /usr/bin/[, /usr/bin/tee" \
2022-11-27 16:00:43 -07:00
| sudo EDITOR='tee -a' visudo
2022-09-14 18:50:21 -06:00
# Copy over cgi and libs
2022-11-27 16:00:43 -07:00
COPY fed.cgi /usr/lib/cgi-bin/index.cgi
2022-09-14 18:50:21 -06:00
# TODO: Copy only needed libs
COPY lib/ /usr/lib/wagon/
2022-09-14 18:50:21 -06:00
2022-09-14 14:44:00 -06:00
# Run time!
2022-11-27 16:00:43 -07:00
EXPOSE ${PORT}
2024-01-11 11:28:52 -07:00
CMD ["apachectl", "-D", "FOREGROUND"]