Skip to content

Commit

Permalink
define multi entry points
Browse files Browse the repository at this point in the history
  • Loading branch information
Test committed Sep 17, 2024
1 parent b296991 commit 6c27122
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 18 deletions.
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ COPY . ./
# Copy the entrypoint scripts
COPY entrypoint.sh ./entrypoint.sh
COPY sidekiq-entrypoint.sh ./sidekiq-entrypoint.sh
COPY rails-entrypoint.sh ./rails-entrypoint.sh

# Make sure the entrypoint scripts are executable
RUN chmod +x entrypoint.sh sidekiq-entrypoint.sh
Expand All @@ -35,5 +36,7 @@ RUN SECRET_KEY_BASE=dummy_key RAILS_ENV=production bundle exec rake assets:preco
# Expose the application port
EXPOSE 3000

ENTRYPOINT ["./entrypoint.sh"]

# Default command to run the Rails server
CMD bundle exec rails db:migrate && bundle exec rails server -b 0.0.0.0 -p 3000
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.10-alpha
1.0.11-alpha
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
web:
build: .
entrypoint: ["./entrypoint.sh"]
entrypoint: ["./rails-entrypoint.sh"]
volumes:
- .:/app
- ./storage:/app/storage
Expand Down
21 changes: 5 additions & 16 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
#!/bin/bash
set -e
echo "Starting entrypoint.sh"
export REDIS_URL=redis://redis:6379/1

# Ensure SECRET_KEY_BASE is set
if [ -z "$SECRET_KEY_BASE" ]; then
export SECRET_KEY_BASE=$(bin/rails secret)
fi
# Call the first entrypoint script
./rails-entrypoint.sh

echo "Running bundle exec rake assets:precompile"
rm -f /app/tmp/pids/server.pid
# Call the second entrypoint script
./sidekiq-entrypoint.sh

echo "Running bundle exec rake assets:precompile"
bundle exec rake assets:precompile RAILS_ENV=production

echo "Running bundle exec rails db:migrate RAILS_ENV=production"
bundle exec rails db:migrate RAILS_ENV=production

echo "Executing final command: $@"
# Finally, execute the command passed to the Docker container
exec "$@"
21 changes: 21 additions & 0 deletions rails-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
set -e
echo "Starting entrypoint.sh"
export REDIS_URL=redis://redis:6379/1

# Ensure SECRET_KEY_BASE is set
if [ -z "$SECRET_KEY_BASE" ]; then
export SECRET_KEY_BASE=$(bin/rails secret)
fi

echo "Running bundle exec rake assets:precompile"
rm -f /app/tmp/pids/server.pid

echo "Running bundle exec rake assets:precompile"
bundle exec rake assets:precompile RAILS_ENV=production

echo "Running bundle exec rails db:migrate RAILS_ENV=production"
bundle exec rails db:migrate RAILS_ENV=production

echo "Executing final command: $@"
exec "$@"

0 comments on commit 6c27122

Please sign in to comment.