Skip to content

Commit

Permalink
Added support for production and other modes
Browse files Browse the repository at this point in the history
  • Loading branch information
amarzial committed Oct 8, 2021
1 parent 72deb4d commit a3f4eb8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Expand Down
11 changes: 0 additions & 11 deletions config/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions config/run.sh
Original file line number Diff line number Diff line change
@@ -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 $!
2 changes: 1 addition & 1 deletion config/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a3f4eb8

Please sign in to comment.