mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-12-15 16:06:17 +00:00
chore: fix docker (hopefully)
This commit is contained in:
@@ -96,9 +96,10 @@ LABEL maintainer="dselen@nerthus.nl"
|
|||||||
|
|
||||||
# Install only the runtime dependencies
|
# Install only the runtime dependencies
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
iproute2 iptables openresolv \
|
iproute2 iptables \
|
||||||
bash curl procps openrc \
|
bash curl procps openrc \
|
||||||
tzdata wireguard-tools
|
tzdata wireguard-tools envsubst
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
|
|
||||||
# Copy only the final binaries from the AWG builder stages
|
# Copy only the final binaries from the AWG builder stages
|
||||||
COPY --from=awg-go /usr/bin/amneziawg-go /usr/bin/amneziawg-go
|
COPY --from=awg-go /usr/bin/amneziawg-go /usr/bin/amneziawg-go
|
||||||
@@ -107,6 +108,7 @@ COPY --from=awg-tools /workspace/awg-tools/src/wg-quick/linux.bash /usr/bin/awg-
|
|||||||
|
|
||||||
# Environment variables
|
# Environment variables
|
||||||
ARG wg_net="10.0.0.1"
|
ARG wg_net="10.0.0.1"
|
||||||
|
ARG wg_subn="24"
|
||||||
ARG wg_port="51820"
|
ARG wg_port="51820"
|
||||||
ENV TZ="Europe/Amsterdam" \
|
ENV TZ="Europe/Amsterdam" \
|
||||||
global_dns="9.9.9.9" \
|
global_dns="9.9.9.9" \
|
||||||
@@ -117,32 +119,34 @@ ENV TZ="Europe/Amsterdam" \
|
|||||||
# Create directories needed for operation
|
# Create directories needed for operation
|
||||||
RUN mkdir /data /configs -p ${WGDASH}/src /etc/amnezia/amneziawg
|
RUN mkdir /data /configs -p ${WGDASH}/src /etc/amnezia/amneziawg
|
||||||
|
|
||||||
# Copy the python virtual environment from the pip-builder stage
|
# Copy the venv and source files from local compiled locations or repos
|
||||||
COPY ./src ${WGDASH}/src
|
COPY ./src ${WGDASH}/src
|
||||||
COPY --from=pip-builder /opt/wgdashboard/src/venv /opt/wgdashboard/src/venv
|
COPY --from=pip-builder /opt/wgdashboard/src/venv /opt/wgdashboard/src/venv
|
||||||
|
COPY ./docker/wg0.conf.template /tmp/wg0.conf.template
|
||||||
|
# Copy in the runtime script, essential.
|
||||||
|
COPY ./docker/entrypoint.sh /entrypoint.sh
|
||||||
|
|
||||||
# First WireGuard interface template
|
# First WireGuard interface template
|
||||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
RUN export out_adapt=$(ip -o -4 route show to default | awk '{print $NF}') \
|
||||||
RUN out_adapt=$(ip -o -4 route show to default | awk '{print $NF}') \
|
&& envsubst < /tmp/wg0.conf.template > /configs/wg0.conf.template \
|
||||||
&& echo -e "[Interface]\n\
|
&& chmod 600 /configs/wg0.conf.template \
|
||||||
Address = ${wg_net}/24\n\
|
&& cat /configs/wg0.conf.template
|
||||||
PrivateKey =\n\
|
# && echo -e "[Interface]\n\
|
||||||
PostUp = iptables -t nat -I POSTROUTING 1 -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
#Address = ${wg_net}/${wg_subn}\n\
|
||||||
PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP\n\
|
#PrivateKey =\n\
|
||||||
PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
#PostUp = iptables -t nat -I POSTROUTING 1 -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
||||||
PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\
|
#PostUp = iptables -I FORWARD -i wg0 -o wg0 -j DROP\n\
|
||||||
ListenPort = ${wg_port}\n\
|
#PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE\n\
|
||||||
SaveConfig = true\n\
|
#PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\
|
||||||
DNS = ${global_dns}" > /configs/wg0.conf.template \
|
#ListenPort = ${wg_port}\n\
|
||||||
&& chmod 600 /configs/wg0.conf.template
|
#SaveConfig = true\n\
|
||||||
|
#DNS = ${global_dns}" > /configs/wg0.conf.template \
|
||||||
|
# && chmod 600 /configs/wg0.conf.template
|
||||||
|
|
||||||
# Set a healthcheck to determine the container its health
|
# Set a healthcheck to determine the container its health
|
||||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
|
||||||
CMD sh -c 'pgrep gunicorn > /dev/null && pgrep tail > /dev/null' || exit 1
|
CMD sh -c 'pgrep gunicorn > /dev/null && pgrep tail > /dev/null' || exit 1
|
||||||
|
|
||||||
# Copy in the runtime script, essential.
|
|
||||||
COPY ./docker/entrypoint.sh /entrypoint.sh
|
|
||||||
|
|
||||||
# Expose ports on the container
|
# Expose ports on the container
|
||||||
EXPOSE 10086
|
EXPOSE 10086
|
||||||
WORKDIR $WGDASH/src
|
WORKDIR $WGDASH/src
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ ensure_installation() {
|
|||||||
|
|
||||||
# Setup WireGuard if needed
|
# Setup WireGuard if needed
|
||||||
if [ -z "$(ls -A /etc/wireguard)" ]; then
|
if [ -z "$(ls -A /etc/wireguard)" ]; then
|
||||||
|
cat /configs/wg0.conf.template
|
||||||
cp -a "/configs/wg0.conf.template" "/etc/wireguard/wg0.conf"
|
cp -a "/configs/wg0.conf.template" "/etc/wireguard/wg0.conf"
|
||||||
|
|
||||||
echo "Setting a secure private key."
|
echo "Setting a secure private key."
|
||||||
@@ -192,6 +193,9 @@ start_and_monitor() {
|
|||||||
|
|
||||||
[[ ! -d ${WGDASH}/src/log ]] && mkdir ${WGDASH}/src/log
|
[[ ! -d ${WGDASH}/src/log ]] && mkdir ${WGDASH}/src/log
|
||||||
${WGDASH}/src/venv/bin/gunicorn --config ${WGDASH}/src/gunicorn.conf.py
|
${WGDASH}/src/venv/bin/gunicorn --config ${WGDASH}/src/gunicorn.conf.py
|
||||||
|
|
||||||
|
resolvconf -u
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Loading WGDashboard failed... Look above for details."
|
echo "Loading WGDashboard failed... Look above for details."
|
||||||
fi
|
fi
|
||||||
|
|||||||
8
docker/wg0.conf.template
Normal file
8
docker/wg0.conf.template
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Interface]
|
||||||
|
Address = ${wg_net}/24
|
||||||
|
PrivateKey =
|
||||||
|
PostUp = iptables -t nat -I POSTROUTING 1 -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE; iptables -I FORWARD -i wg0 -o wg0 -j DROP
|
||||||
|
PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQUERADE; iptables -D FORWARD -i wg0 -o wg0 -j DROP
|
||||||
|
ListenPort = ${wg_port}
|
||||||
|
SaveConfig = true
|
||||||
|
DNS = ${global_dns}
|
||||||
Reference in New Issue
Block a user