Skip to content

Commit

Permalink
Merge pull request #682 from cul-it/docker-updates
Browse files Browse the repository at this point in the history
Docker updates
  • Loading branch information
chrisrlc authored Oct 3, 2024
2 parents b07cf1c + 86bbd51 commit 04cc7d5
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 26 deletions.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ FROM dev_base as test
ENV RAILS_ENV=test \
APP_PATH=/exhibits

# Install application gems
WORKDIR $APP_PATH
COPY Gemfile Gemfile.lock ./
RUN bundle install

COPY . .

ENTRYPOINT [ "docker/build_test.sh" ]
Expand Down Expand Up @@ -64,7 +60,7 @@ COPY --chown=${USER}:${GROUP} . .

# Run the web server
EXPOSE 9292
ENTRYPOINT [ "docker/puma.sh" ]
ENTRYPOINT [ "docker/run_dev.sh" ]

################################################################################
# Bundle production/integration/staging environment
Expand Down Expand Up @@ -126,4 +122,4 @@ WORKDIR ${APP_PATH}

# Run the web server
EXPOSE 9292
ENTRYPOINT [ "docker/puma.sh" ]
ENTRYPOINT [ "docker/run.sh" ]
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ gem 'blacklight-spotlight', '~> 3.5'
group :development do
gem 'better_errors' # add command line in browser when errors
gem 'binding_of_caller' # deeper stack trace used by better errors
gem 'letter_opener' # show emails in browser
gem 'listen'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
Expand Down
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ GEM
railties (>= 4.2.0)
legato (0.7.0)
multi_json
letter_opener (1.8.1)
launchy (>= 2.2, < 3)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
Expand Down Expand Up @@ -713,7 +711,6 @@ DEPENDENCIES
irb
jbuilder (~> 2.5)
jquery-rails
letter_opener
listen
mina
mysql2
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
config.active_storage.service = :local

# Configure Email Notifications
config.action_mailer.delivery_method = :letter_opener # Open emails in a web browser
config.action_mailer.delivery_method = :test
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_caching = false

Expand Down
11 changes: 8 additions & 3 deletions docker/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

set -e

# Prepare DB (Migrate if exists; else Create db & Migrate)
sh ./docker/db_prepare.sh
# Install gems
bundle install

# Run the command defined in compose.test.yaml
# If the database exists, migrate. Otherwise setup (create and migrate)
echo "Preparing Database..."
bundle exec rake db:environment:set RAILS_ENV=test db:migrate 2>/dev/null || bundle exec rake db:environment:set RAILS_ENV=test db:create db:schema:load
echo "Database Migration Done!"

# Run commands
exec "$@"
6 changes: 0 additions & 6 deletions docker/db_prepare.sh

This file was deleted.

12 changes: 7 additions & 5 deletions docker/puma.sh → docker/run.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ then
cron
fi

# Prepare DB (Migrate if exists; else Create db & Migrate)
sh ./docker/db_prepare.sh

# Run the command defined in compose.yaml
exec "$@"
# Run db migrations
echo "Preparing Database..."
bundle exec rake db:migrate RAILS_ENV=$RAILS_ENV
echo "Database Migration Done!"

# Start sidekiq
bundle exec sidekiq -L log/sidekiq.log -e $RAILS_ENV -C config/sidekiq.yml -d

# Start the web server
mkdir -p ./tmp/pids
bundle exec puma -C config/puma.rb -e $RAILS_ENV

# Run commands
exec "$@"
18 changes: 18 additions & 0 deletions docker/run_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e

# If the database exists, migrate. Otherwise setup (create and migrate)
echo "Preparing Database..."
bundle exec rake db:migrate 2>/dev/null || bundle exec rake db:create db:schema:load
echo "Database Migration Done!"

# Start sidekiq
bundle exec sidekiq -L log/sidekiq.log -e $RAILS_ENV -C config/sidekiq.yml -d

# Start the web server
mkdir -p ./tmp/pids
bundle exec puma -C config/puma.rb -e $RAILS_ENV

# Run commands
exec "$@"
2 changes: 1 addition & 1 deletion docker/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ done

if [ $interactive = true ]
then
docker compose -p exhibits-test -f compose.test.yaml run --entrypoint=bash webapp
docker compose -p exhibits-test -f compose.test.yaml run webapp bash
else
docker compose -p exhibits-test -f compose.test.yaml run webapp bundle exec rspec
fi
Expand Down

0 comments on commit 04cc7d5

Please sign in to comment.