Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerized dev #1474

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .docker/app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
ARG ALPINE_RUBY_VERSION

FROM ruby:${ALPINE_RUBY_VERSION}-alpine

RUN apk add --update --no-cache \
bash \
build-base \
gcompat \
git \
libxml2-dev \
libxslt-dev \
nodejs \
shared-mime-info \
sqlite-dev \
tzdata \
yarn

RUN mkdir /app
WORKDIR /app

RUN gem update --system && \
gem install bundler && \
bundle config build.nokogiri --use-system-libraries

COPY . .

EXPOSE 3000

CMD [".docker/app/entrypoint.sh"]
8 changes: 8 additions & 0 deletions .docker/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

rm -f /app/.internal_test_app/tmp/pids/server.pid
bundle install
bundle exec rails engine_cart:generate
bundle exec rails arclight:seed
bundle exec rake arclight:server["-p 3000 -b 0.0.0.0"]
6 changes: 6 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ALPINE_RUBY_VERSION=3.2.2
RAILS_VERSION=7.1.2
VIEW_COMPONENT_VERSION=3.8.0
SOLR_PORT=8983
SOLR_URL=http://solr:8983/solr/arclight
SOLR_VERSION=latest
23 changes: 23 additions & 0 deletions README.md
dl-maura marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,29 @@ Then visit http://localhost:3000. It will also start a Solr instance on port 898

You can also run `bin/console` for an interactive prompt that will allow you to experiment.

### Docker Development Environment

**NOTE:** If you are on an M1/M2 mac, you will have to do the following first:

```sh
$ export DOCKER_DEFAULT_PLATFORM=linux/amd64
```

Another option for a local development environment is to use the included docker materials to spin up a local dockerized development instance. After cloning this repository, run the following command inside the project directory:

```sh
$ docker compose up
```

or for a full rebuild and with containers running in the background:

```sh
$ docker-compose -f docker-compose.yml up --build -d --force-recreate
```

Either should bring up a dockerized solr and arclight running at ports 8983 and 3000, with the seed data indexed. This uses a mount which allows you to make changes in your IDE/text editor of choice and see them reflected in the running app without a restart.


### Releasing
dl-maura marked this conversation as resolved.
Show resolved Hide resolved

#### To release a new gem:
Expand Down
35 changes: 31 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
version: "3.7"

services:
app:
build:
context: .
dockerfile: .docker/app/Dockerfile
args:
- ALPINE_RUBY_VERSION
# mounting . is causing seg-fault on macosx
volumes:
- .:/app
depends_on:
- solr
env_file:
- .env
ports:
- "3000:3000"
environment:
- SOLR_URL # Set via environment variable or use default defined in .env file
- RAILS_VERSION # Set via environment variable or use default defined in .env file
- VIEW_COMPONENT_VERSION # Set via environment variable or use default defined in .env file
- SOLR_ENV=docker-compose
- ENGINE_CART_RAILS_OPTIONS=--skip-git --skip-listen --skip-spring --skip-keeps --skip-action-cable --skip-coffee --skip-test --skip-solr

solr:
image: solr:latest
environment:
- SOLR_PORT # Set via environment variable or use default defined in .env file
- SOLR_VERSION # Set via environment variable or use default defined in .env file
image: "solr:${SOLR_VERSION}"
volumes:
- $PWD/solr/conf:/opt/solr/conf
- ./solr/conf:/opt/solr/conf
env_file:
- .env
ports:
- 8983:8983
- "${SOLR_PORT}:8983"
entrypoint:
- docker-entrypoint.sh
- solr-precreate
- blacklight-core
- arclight
- /opt/solr/conf
- "-Xms256m"
- "-Xmx512m"
54 changes: 42 additions & 12 deletions tasks/arclight.rake
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,33 @@ namespace :arclight do
Rake::Task['engine_cart:generate'].invoke
end

print 'Starting Solr...'
SolrWrapper.wrap do |solr|
puts 'done.'
solr.with_collection do
Rake::Task['arclight:seed'].invoke
if ENV['SOLR_ENV'] == 'docker-compose'
puts "Using docker solr"
within_test_app do
system "bundle exec rails s #{args[:rails_server_args]}"
end
elsif system('docker-compose -v')
# We're not running docker-compose up but still want to use a docker instance of solr.
begin
puts "Starting Solr"
system_with_error_handling "docker-compose up -d solr"
within_test_app do
system "bundle exec rails s #{args[:rails_server_args]}"
end
ensure
puts "Stopping Solr"
system_with_error_handling "docker-compose stop solr"
end
else
print 'Starting Solr...'
SolrWrapper.wrap do |solr|
puts 'done.'
solr.with_collection do
Rake::Task['arclight:seed'].invoke
within_test_app do
system "bundle exec rails s #{args[:rails_server_args]}"
end
end
end
end
end
Expand All @@ -59,13 +78,24 @@ namespace :arclight do
Dir.glob('spec/fixtures/ead/*').each do |dir|
next unless File.directory?(dir)

within_test_app do
# Sets the REPOSITORY_ID to the name of the file's containing directory
system("REPOSITORY_ID=#{File.basename(dir)} " \
"REPOSITORY_FILE=#{Arclight::Engine.root}/spec/fixtures/config/repositories.yml " \
"DIR=#{Arclight::Engine.root}/#{dir} " \
'SOLR_URL=http://127.0.0.1:8983/solr/blacklight-core ' \
'rake arclight:index_dir')
if ENV['SOLR_ENV'] == 'docker-compose' or system('docker-compose -v')
within_test_app do
# Sets the REPOSITORY_ID to the name of the file's containing directory
system("REPOSITORY_ID=#{File.basename(dir)} " \
"REPOSITORY_FILE=#{Arclight::Engine.root}/spec/fixtures/config/repositories.yml " \
"DIR=#{Arclight::Engine.root}/#{dir} " \
"SOLR_URL=#{ENV['SOLR_URL']} " \
'rake arclight:index_dir')
end
else
within_test_app do
# Sets the REPOSITORY_ID to the name of the file's containing directory
system("REPOSITORY_ID=#{File.basename(dir)} " \
"REPOSITORY_FILE=#{Arclight::Engine.root}/spec/fixtures/config/repositories.yml " \
"DIR=#{Arclight::Engine.root}/#{dir} " \
'SOLR_URL=http://127.0.0.1:8983/solr/blacklight-core ' \
'rake arclight:index_dir')
end
end
end
end
Expand Down
Loading