From a3f4eb8cdebd88527bea0c3b7e7aec079a27e7aa Mon Sep 17 00:00:00 2001 From: Alessandro Marzialetti Date: Fri, 8 Oct 2021 16:02:00 +0200 Subject: [PATCH] Added support for production and other modes --- Dockerfile | 3 ++- config/init.sh | 11 ----------- config/run.sh | 17 +++++++++++++++++ config/supervisord.conf | 2 +- 4 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 config/run.sh diff --git a/Dockerfile b/Dockerfile index 92c0c67..daf0042 100644 --- a/Dockerfile +++ b/Dockerfile @@ -22,10 +22,11 @@ WORKDIR /docusaurus ADD config/init.sh / ADD config/auto_update_crontab.txt / ADD config/auto_update_job.sh / +ADD config/run.sh / COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf # Set files permission -RUN chmod a+x /init.sh /auto_update_job.sh +RUN chmod a+x /init.sh /auto_update_job.sh /run.sh EXPOSE 80 VOLUME [ "/docusaurus" ] diff --git a/config/init.sh b/config/init.sh index 5ad9007..48d771e 100644 --- a/config/init.sh +++ b/config/init.sh @@ -61,17 +61,6 @@ else msg "Node modules already exist in $DOCU_PATH/$WEBSITE_NAME/node_modules" fi -#msg "Will run this Node service as $RUN_MODE mode..." -#if [[ "$RUN_MODE" == "production" ]]; then -# msg "Build current sources..." -# cd "$WEB_SRC_PATH" || msg "There's no directory named $WEB_SRC_PATH. Program will be closed." && exit -# yarn build & -#elif [[ "$RUN_MODE" != "production" ]] && [[ "$RUN_MODE" != "development" ]]; then -# msg "This "$RUN_MODE" mode is unknown as a default Node.js service mode. You should do know what you do." -# yarn "$RUN_MODE" & -#fi -#[[ "$!" -gt 0 ]] && wait $! - if [[ "$RUN_MODE" != "development" ]]; then msg "Other mode is not supported yet. It will run as a development mode." fi diff --git a/config/run.sh b/config/run.sh new file mode 100644 index 0000000..3fd3941 --- /dev/null +++ b/config/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash +msg() { + echo -E "/* $1 */" +} + +msg "Will run this Node service as $RUN_MODE mode..." + +if [[ "$RUN_MODE" == "development" ]]; then + yarn run start --port 80 --host 0.0.0.0 & +elif [[ "$RUN_MODE" == "production" ]]; then + msg "Build current sources..." + yarn run serve --build --port 80 --host 0.0.0.0 & +elif [[ "$RUN_MODE" != "production" ]] && [[ "$RUN_MODE" != "development" ]]; then + msg "This "$RUN_MODE" mode is unknown as a default Node.js service mode. You should do know what you do." + yarn run "$RUN_MODE" & +fi +[[ "$!" -gt 0 ]] && wait $! diff --git a/config/supervisord.conf b/config/supervisord.conf index 09777d9..a49f28a 100644 --- a/config/supervisord.conf +++ b/config/supervisord.conf @@ -4,7 +4,7 @@ user=root [program:docusaurus] directory=/docusaurus/website -command=yarn run start --port 80 --host 0.0.0.0 +command=/run.sh stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr