Skip to content

Commit

Permalink
switch to production
Browse files Browse the repository at this point in the history
  • Loading branch information
Test committed Sep 13, 2024
1 parent 240a38f commit 47a915e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 13 deletions.
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,23 @@ WORKDIR /app
COPY Gemfile* ./

# Install the Ruby and Rails dependencies
RUN bundle install
RUN bundle install --without development test

# Copy the application code
COPY . ./

# Ensure the entrypoint scripts are included in the image
# Copy the entrypoint scripts
COPY entrypoint.sh ./entrypoint.sh
COPY sidekiq-entrypoint.sh ./sidekiq-entrypoint.sh

# Make sure the entrypoint scripts are executable
RUN chmod +x entrypoint.sh sidekiq-entrypoint.sh

EXPOSE 3000
# Define the default command to be run in the container
# Precompile assets for production
RUN SECRET_KEY_BASE=dummy_key RAILS_ENV=production bundle exec rake assets:precompile

# Expose the application port
EXPOSE 3000

CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"]
# Default command to run the Rails server
CMD ["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.6-alpha
1.0.7-alpha
18 changes: 15 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ services:
ports:
- "3000:3000"
environment:
RAILS_ENV: development
RAILS_ENV: production
REDIS_URL: redis://redis:6379/1
depends_on:
- db
- redis

worker:
Expand All @@ -21,14 +22,25 @@ services:
- .:/app
- ./storage:/app/storage
environment:
RAILS_ENV: development
RAILS_ENV: production
REDIS_URL: redis://redis:6379/1
depends_on:
- db
- redis

redis:
image: redis:6.2.5
ports:
- "6379:6379"

db:
image: postgres:13
environment:
POSTGRES_USER: username
POSTGRES_PASSWORD: password
POSTGRES_DB: mydatabase
volumes:
- db-data:/var/lib/postgresql/data

volumes:
db-data:
db-data:
10 changes: 7 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@ set -e
echo "Starting entrypoint.sh"
export REDIS_URL=redis://redis:6379/1

export SECRET_KEY_BASE=$(bin/rails secret)
# 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
bundle exec rake assets:precompile RAILS_ENV=production

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

echo "Executing final command: $@"
exec "$@"
10 changes: 9 additions & 1 deletion sidekiq-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
#!/bin/bash
set -e

# Ensure Redis URL is set correctly
export REDIS_URL=redis://redis:6379/1
export SECRET_KEY_BASE=$(bin/rails secret)

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

# Migrate the database before starting Sidekiq
bundle exec rails db:migrate RAILS_ENV=production

exec "$@"

0 comments on commit 47a915e

Please sign in to comment.