From f75d1d77ae222818fe010c178242006200e08377 Mon Sep 17 00:00:00 2001 From: Zibbp Date: Thu, 12 Dec 2024 23:15:57 +0000 Subject: [PATCH] add supervisord to container --- .dockerignore | 20 +++++++++++++++++++- Dockerfile | 3 ++- entrypoint.sh | 14 ++------------ supervisord.conf | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 supervisord.conf diff --git a/.dockerignore b/.dockerignore index 65c8dae4..f03e0998 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,4 +1,22 @@ .github dev tmp -bin \ No newline at end of file +bin +/frontend/node_modules +/frontend/.pnp +/frontend/.pnp.* +/frontend/.yarn/* +!.yarn/patches +!.yarn/plugins +!.yarn/releases +!.yarn/versions +/coverage +/frontend/.next/ +/out/ +/build +/frontend/npm-debug.log* +/frontend/yarn-debug.log* +/frontend/yarn-error.log* +/frontend/.env* +/frontend/*.tsbuildinfo +/frontend/next-env.d.ts diff --git a/Dockerfile b/Dockerfile index cb3e65a3..2a793972 100644 --- a/Dockerfile +++ b/Dockerfile @@ -73,7 +73,7 @@ WORKDIR /opt/app # Install dependencies RUN apt-get update && apt-get install -y --no-install-recommends \ - python3 python3-pip fontconfig ffmpeg tzdata procps \ + python3 python3-pip fontconfig ffmpeg tzdata procps supervisor \ fonts-noto-core fonts-noto-cjk fonts-noto-extra fonts-inter \ curl \ && rm -rf /var/lib/apt/lists/* \ @@ -138,6 +138,7 @@ ENV HOSTNAME="0.0.0.0" # Setup entrypoint COPY entrypoint.sh /usr/local/bin/ RUN chmod +x /usr/local/bin/entrypoint.sh +COPY supervisord.conf /opt/app/supervisord.conf EXPOSE 4000 ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh index 10bf40e2..82cc3365 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -33,15 +33,5 @@ gosu abc fc-cache -f export DOTNET_BUNDLE_EXTRACT_BASE_DIR=/tmp export FONTCONFIG_CACHE=/var/cache/fontconfig -# start api and worker as user abc -gosu abc /opt/app/ganymede-api & -api_pid=$! - -# delay 5 seconds to wait for api to start -sleep 5 - -gosu abc /opt/app/ganymede-worker & -worker_pid=$! - -# wait -wait $api_pid $worker_pid \ No newline at end of file +# start applications +/usr/bin/supervisord -c /opt/app/supervisord.conf \ No newline at end of file diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 00000000..3ea754de --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,32 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord.log +pidfile=/var/run/supervisord.pid + +[program:api] +command=gosu abc /opt/app/ganymede-api +autostart=true +autorestart=true +stderr_logfile=/dev/stderr +stdout_logfile=/dev/stdout +stderr_logfile_maxbytes=0 +stdout_logfile_maxbytes=0 + +[program:worker] +command=gosu abc /opt/app/ganymede-worker +autostart=true +autorestart=true +stderr_logfile=/dev/stderr +stdout_logfile=/dev/stdout +stderr_logfile_maxbytes=0 +stdout_logfile_maxbytes=0 + +[program:frontend] +directory=/opt/app +command=node server.js +autostart=true +autorestart=true +stderr_logfile=/dev/stderr +stdout_logfile=/dev/stdout +stderr_logfile_maxbytes=0 +stdout_logfile_maxbytes=0