From ba5ba2f1d64f6f416dead825976a55db8fb6db64 Mon Sep 17 00:00:00 2001 From: Daan Date: Thu, 24 Oct 2024 00:09:27 +0200 Subject: [PATCH] Removed copy step in entrypoint.sh Tested updating, works as long as presistent files are compatible. --- Dockerfile | 12 +++++------- entrypoint.sh | 39 ++++++++++++++------------------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6597624..8f4a152 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,11 +24,9 @@ ENV WGDASH=/opt/wireguarddashboard # Removing the Linux Image package to preserve space on the image, for this reason also deleting apt lists, to be able to install packages: run apt update. # Doing WireGuard Dashboard installation measures. Modify the git clone command to get the preferred version, with a specific branch for example. -RUN mkdir -p /setup/conf \ - && mkdir /setup/app \ - && mkdir ${WGDASH} \ - && mkdir /data -COPY ./src /setup/app/src +RUN mkdir -p /data/conf \ + && mkdir -p ${WGDASH}/src +COPY ./src ${WGDASH}/src # Set the volume to be used for WireGuard configuration persistency. Can be ignored so it does not create volumes when not specified. #VOLUME /etc/wireguard @@ -47,8 +45,8 @@ PreDown = iptables -t nat -D POSTROUTING -s ${wg_net}/24 -o ${out_adapt} -j MASQ PreDown = iptables -D FORWARD -i wg0 -o wg0 -j DROP\n\ ListenPort = ${wg_port}\n\ SaveConfig = true\n\ -DNS = ${global_dns}" > /setup/conf/wg0.conf \ - && chmod 600 /setup/conf/wg0.conf +DNS = ${global_dns}" > /data/conf/wg0.conf \ + && chmod 600 /data/conf/wg0.conf # Defining a way for Docker to check the health of the container. In this case: checking the login URL. HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ diff --git a/entrypoint.sh b/entrypoint.sh index f46134c..c33e382 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -5,42 +5,32 @@ echo "Starting the WireGuard Dashboard Docker container." ensure_installation() { # When using a custom directory to store the files, this part moves over and makes sure the installation continues. - echo "Checking if everything is present." + echo "Quick-installing..." - if [ -z "$(ls -A "${WGDASH}")" ]; then # [ ! -f "/data/wg-dashboard.ini" ] && [ ! -d "/data/db" ] - echo "Detected empty directory, moving over..." + [ ! -d "/data/db" ] && echo "Creating database dir" && mkdir /data/db + ln -s /data/db "${WGDASH}/src/db" - # Moving over source files. (This does not include src/db and src/wg-dashboard.ini folder and file.) - mv -v /setup/app/* "${WGDASH}" + [ ! -f "/data/wg-dashboard.ini" ] && echo "Creating wg-dashboard.ini file" && touch /data/wg-dashboard.ini + ln -s /data/wg-dashboard.ini "${WGDASH}/src/wg-dashboard.ini" - [ ! -d "/data/db" ] && echo "Creating database dir" && mkdir /data/db - ln -s /data/db "${WGDASH}/src/db" + python3 -m venv "${WGDASH}"/src/venv + . "${WGDASH}/src/venv/bin/activate" - [ ! -f "/data/wg-dashboard.ini" ] && echo "Creating wg-dashboard.ini file" && touch /data/wg-dashboard.ini - ln -s /data/wg-dashboard.ini "${WGDASH}/src/wg-dashboard.ini" + mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages + mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages + chmod +x "${WGDASH}"/src/wgd.sh + cd "${WGDASH}"/src || exit + ./wgd.sh install - python3 -m venv "${WGDASH}"/src/venv - . "${WGDASH}/src/venv/bin/activate" - - mv /usr/lib/python3.12/site-packages/psutil* "${WGDASH}"/src/venv/lib/python3.12/site-packages - mv /usr/lib/python3.12/site-packages/bcrypt* "${WGDASH}"/src/venv/lib/python3.12/site-packages - - chmod +x "${WGDASH}"/src/wgd.sh - cd "${WGDASH}"/src || exit - ./wgd.sh install - - echo "Looks like the installation succesfully moved over." - else - echo "Looks like everything is present. Or the directory is not empty." - fi + echo "Looks like the installation succeeded." # This first step is to ensure the wg0.conf file exists, and if not, then its copied over from the ephemeral container storage. # This is done so WGDashboard it works out of the box if [ ! -f "/etc/wireguard/wg0.conf" ]; then echo "Standard wg0 Configuration file not found, grabbing template." - cp -a "/setup/conf/wg0.conf" "/etc/wireguard/wg0.conf" + cp -a "/data/conf/wg0.conf" "/etc/wireguard/wg0.conf" echo "Setting a secure private key." # SORRY 4 BE4 - Daan @@ -89,7 +79,6 @@ clean_up() { echo "Removed unneeded logs!" } - set_envvars() { printf "\n------------- SETTING ENVIRONMENT VARIABLES ----------------\n"