Skip to content

Commit

Permalink
add supervisord to container
Browse files Browse the repository at this point in the history
  • Loading branch information
Zibbp committed Dec 12, 2024
1 parent 3da9507 commit f75d1d7
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
20 changes: 19 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
.github
dev
tmp
bin
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
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/* \
Expand Down Expand Up @@ -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"]
14 changes: 2 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# start applications
/usr/bin/supervisord -c /opt/app/supervisord.conf
32 changes: 32 additions & 0 deletions supervisord.conf
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit f75d1d7

Please sign in to comment.