Skip to content

Commit

Permalink
docker tweeks to allow better local testing (#729)
Browse files Browse the repository at this point in the history
  • Loading branch information
rococodogs authored May 18, 2021
1 parent 5f3e147 commit aff15ca
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ FROM ruby:2.4.3 as spot-base
# add node + yarn repositories (do we need both?)
RUN apt-get update && apt-get install -y -qq apt-transport-https apt-utils \
&& (curl -sL https://deb.nodesource.com/setup_10.x | bash) \
&& (curl -fsSL https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -) \
&& (curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -) \
&& (echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list)

Expand Down
11 changes: 0 additions & 11 deletions bin/create-test-db.sh

This file was deleted.

1 change: 1 addition & 0 deletions bin/create-test-db.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE DATABASE spot_test OWNER spot_dev_user;
7 changes: 4 additions & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ default: &default
pool: <%= ENV.fetch('RAILS_MAX_THREADS') { 5 } %>
timeout: 5000
encoding: unicode
host: localhost
host: <%= ENV.fetch('PSQL_HOST') { 'localhost' } %>
username: "<%= ENV.fetch('PSQL_USER') %>"
password: "<%= ENV.fetch('PSQL_PASSWORD') { '' } %>"

development:
<<: *default
database: "<%= ENV.fetch('PSQL_DATABASE') { 'spot_dev' } %>"

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
username: "<%= ENV.fetch('PSQL_USER') { '' } %>"
password: "<%= ENV.fetch('PSQL_PASSWORD') { '' } %>"
database: "<%= ENV.fetch('PSQL_DATABASE') { 'spot_test' } %>"

production:
Expand Down
27 changes: 23 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@ volumes:
redis:

services:
app: &app
app:
build: .
volumes:
- .:/spot
- rails_public:/spot/public
- rails_tmp:/spot/tmp
ports:
- "3000:3000"
env_file: .env
environment: &dev_environment
CAS_BASE_URL: ''
DEV_USER: [email protected]
FEDORA_URL: http://fedora:8080/rest
FEDORA_TEST_URL: http://fedora:8080/rest
FITS_SERVLET_URL: http://fitsservlet:8080/fits
IIIF_BASE_URL: http://localhost:8182/iiif/2
PSQL_PASSWORD: spot_dev_pw
PSQL_HOST: db
PSQL_USER: spot_dev_user
RAILS_ENV: development
RAILS_LOG_TO_STDOUT: 'true'
REDIS_URL: redis://redis:6379
SOLR_URL: http://solr:8983/solr/spot-development
SOLR_TEST_URL: http://solr:8983/solr/spot-test
URL_HOST: http://localhost:3000
restart: always
entrypoint: ["bin/spot-dev-entrypoint.sh"]
command: ["bundle", "exec", "rails", "s", "-p", "3000", "-b", "0.0.0.0"]
Expand Down Expand Up @@ -49,16 +64,18 @@ services:
image: postgres:alpine
volumes:
- db:/data
- ./bin/create-test-db.sh:/docker-entrypoint-initdb.d/10-create-test-db.sh
- ./bin/create-test-db.sql:/docker-entrypoint-initdb.d/10-create-test-db.sql
environment:
PGDATA: /data
POSTGRES_DB: spot_dev
POSTGRES_USER: spot_dev_user
POSTGRES_PASSWORD: spot_dev_pw
restart: always

db_migrate:
build: .
env_file: .env
environment:
<<: *dev_environment
entrypoint: ["sh", "-c"]
command: bin/migrate-and-seed-db.sh
depends_on:
Expand Down Expand Up @@ -115,6 +132,8 @@ services:
- rails_tmp:/spot/tmp
ports:
- "3003:3000"
environment:
<<: *dev_environment
restart: always
depends_on:
- db_migrate
Expand Down
11 changes: 9 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,15 @@
allow_localhost: true,
net_http_connect_on_start: true,

# let webdrivers gem fetch the chrome browser
allow: 'chromedriver.storage.googleapis.com'
# let webdrivers gem fetch the chrome browser and
# account for our aliased services via docker
allow: %w[
chromedriver.storage.googleapis.com
db
fedora
fitsservlet
solr
]
)

Shoulda::Matchers.configure do |config|
Expand Down

0 comments on commit aff15ca

Please sign in to comment.