Setup config for deploying both worker and web (#362)

This commit is contained in:
Max Wofford 2025-06-25 14:44:57 -04:00 committed by GitHub
parent 97f8119e8d
commit 7c5b869bce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 47 additions and 3 deletions

View file

@ -74,6 +74,6 @@ USER 1000:1000
# Entrypoint prepares the database.
ENTRYPOINT ["/rails/bin/docker-entrypoint"]
# Start either web server or job worker based on WORKER env var
# Start either web server or job worker based on PROCESS_TYPE env var
EXPOSE 80
CMD ["./bin/thrust", "./bin/rails", "server"]
CMD ["./bin/start-process"]

2
Procfile Normal file
View file

@ -0,0 +1,2 @@
web: bundle exec rails server -b 0.0.0.0 -p $PORT
worker: bundle exec good_job start

18
bin/start-process Executable file
View file

@ -0,0 +1,18 @@
#!/bin/bash -e
# Start the appropriate process based on PROCESS_TYPE environment variable
case "$PROCESS_TYPE" in
web)
echo "Starting web server..."
exec ./bin/thrust ./bin/rails server -b 0.0.0.0 -p ${PORT:-80}
;;
worker)
echo "Starting GoodJob worker..."
exec bundle exec good_job start
;;
*)
echo "Unknown PROCESS_TYPE: $PROCESS_TYPE"
echo "Valid options: web, worker"
exit 1
;;
esac

View file

@ -9,7 +9,7 @@ Rails.application.configure do
config.good_job.poll_interval = -1 # Disable polling
config.good_job.execution_mode = :inline # Run jobs inline in development
else
config.good_job.execution_mode = :async
config.good_job.execution_mode = :external
end
config.good_job.enable_cron = Rails.env.production?

View file

@ -0,0 +1,24 @@
version: '3.8'
services:
web:
build: .
environment:
- PROCESS_TYPE=web
- PORT=80
- RAILS_ENV=production
- DATABASE_URL=${DATABASE_URL}
- RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
ports:
- "80:80"
depends_on:
- worker
worker:
build: .
environment:
- PROCESS_TYPE=worker
- RAILS_ENV=production
- DATABASE_URL=${DATABASE_URL}
- RAILS_MASTER_KEY=${RAILS_MASTER_KEY}
# No ports exposed for worker