diff --git a/Dockerfile b/Dockerfile index eaecdfa..575be02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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"] \ No newline at end of file +# Default command to run the Rails server +CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"] diff --git a/VERSION b/VERSION index b2627f2..2638921 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.0.6-alpha \ No newline at end of file +1.0.7-alpha \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 8ea9003..4d2a695 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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: @@ -21,8 +22,10 @@ services: - .:/app - ./storage:/app/storage environment: - RAILS_ENV: development + RAILS_ENV: production + REDIS_URL: redis://redis:6379/1 depends_on: + - db - redis redis: @@ -30,5 +33,14 @@ services: 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: \ No newline at end of file + db-data: diff --git a/entrypoint.sh b/entrypoint.sh index 306530a..d189d04 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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 "$@" diff --git a/sidekiq-entrypoint.sh b/sidekiq-entrypoint.sh index 31fd54d..1ad4212 100755 --- a/sidekiq-entrypoint.sh +++ b/sidekiq-entrypoint.sh @@ -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 "$@"