Skip to content

Commit 8359549

Browse files
authored
Merge pull request #35 from blocknotes/dev/docker-setup-2
Dev: improve Docker setup
2 parents d1bbf09 + 953d426 commit 8359549

23 files changed

+178
-137
lines changed

.dockerignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/Makefile
2+
/LICENSE.txt
3+
/Gemfile.lock
4+
/extra/init.sh
5+
6+
/app
7+
/bin
8+
/coverage
9+
/gemfiles
10+
/spec/dummy/db/*.sqlite3
11+
/spec/dummy/log
12+
/spec/dummy/tmp
13+
/spec/dummy/**/*_spec.rb
14+
15+
/**/*.md

.env

Lines changed: 0 additions & 2 deletions
This file was deleted.

.github/workflows/specs_rails70.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
ruby-version: ${{ matrix.ruby }}
3030
bundler-cache: true
3131

32+
- name: Database setup
33+
run: bin/rails db:reset db:test:prepare
34+
3235
- name: Run tests
3336
run: bundle exec rspec --profile
3437

.github/workflows/specs_rails71.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
ruby-version: ${{ matrix.ruby }}
3030
bundler-cache: true
3131

32+
- name: Database setup
33+
run: bin/rails db:reset db:test:prepare
34+
3235
- name: Run tests
3336
run: bundle exec rspec --profile
3437

.github/workflows/specs_rails72.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
ruby-version: ${{ matrix.ruby }}
3030
bundler-cache: true
3131

32+
- name: Database setup
33+
run: bin/rails db:reset db:test:prepare
34+
3235
- name: Run tests
3336
run: bundle exec rspec --profile
3437

.github/workflows/specs_rails80.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ jobs:
2929
ruby-version: ${{ matrix.ruby }}
3030
bundler-cache: true
3131

32+
- name: Database setup
33+
run: bin/rails db:reset db:test:prepare
34+
3235
- name: Run tests
3336
run: bundle exec rspec --profile
3437

Gemfile

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,21 @@
33
source 'https://rubygems.org'
44

55
if ENV['DEVEL'] == '1'
6-
rails_ver = ENV.fetch('RAILS_VERSION')
7-
gem 'rails', rails_ver
6+
rails_ver = ENV.fetch('RAILS_VERSION', '')
7+
activeadmin_ver = ENV.fetch('ACTIVEADMIN_VERSION', '')
8+
9+
if rails_ver.empty?
10+
gem 'rails'
11+
else
12+
gem 'rails', "~> #{rails_ver}"
13+
end
14+
15+
if activeadmin_ver.empty?
16+
gem 'activeadmin'
17+
else
18+
gem 'activeadmin', "~> #{activeadmin_ver}"
19+
end
820

9-
gem 'activeadmin', ENV.fetch('ACTIVEADMIN_VERSION')
1021
gem 'activeadmin_dynamic_fields', path: './'
1122
gem 'appraisal', '~> 2.4'
1223

Makefile

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,33 @@
1+
include extra/.env
2+
13
help:
2-
@echo "Main targets: up / down / console / shell"
4+
@echo "Main targets: build / specs / up / server / specs / shell"
35

46
# Docker commands
5-
down:
6-
docker compose down
7-
8-
up:
9-
docker compose up
107

11-
attach:
12-
docker compose attach app
8+
build:
9+
@rm -f Gemfile.lock
10+
@docker compose -f extra/docker-compose.yml build
1311

14-
up_attach:
15-
docker compose up -d && docker compose attach app
12+
up: build
13+
@docker compose -f extra/docker-compose.yml up
1614

1715
cleanup:
18-
docker container rm -f activeadmin_dynamic_fields_app && docker image rm -f activeadmin_dynamic_fields-app
16+
@docker compose -f extra/docker-compose.yml down --volumes --rmi local --remove-orphans
1917

20-
# Rails specific commands
21-
console:
22-
docker compose exec -e "PAGER=more" app bin/rails console
18+
# App commands
2319

24-
routes:
25-
docker compose exec app bin/rails routes
20+
server:
21+
@docker compose -f extra/docker-compose.yml exec app bin/rails s -b 0.0.0.0 -p ${SERVER_PORT}
2622

2723
specs:
28-
docker compose exec app bin/rspec --fail-fast
24+
@docker compose -f extra/docker-compose.yml exec app bin/rspec --fail-fast
25+
26+
lint:
27+
@docker compose -f extra/docker-compose.yml exec app bin/rubocop
2928

30-
# Other commands
31-
bundle:
32-
docker compose exec app bundle
29+
appraisal_update:
30+
@docker compose -f extra/docker-compose.yml exec app bin/appraisal update
3331

3432
shell:
35-
docker compose exec -e "PAGER=more" app bash
36-
37-
lint:
38-
docker compose exec app bin/rubocop
33+
@docker compose -f extra/docker-compose.yml exec app bash

README.md

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -239,50 +239,7 @@ The link url is loaded via AJAX before opening the dialog.
239239
240240
Project created by [Mattia Roccoberton](http://blocknot.es), thanks also to the good guys that opened issues and pull requests from time to time.
241241
242-
There 3 ways to interact with this project:
243-
244-
1) Using Docker:
245-
246-
```sh
247-
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
248-
make up
249-
# Enter in a Rails console (with the dummy app started):
250-
make console
251-
# Enter in a shell (with the dummy app started):
252-
make shell
253-
# Run the linter on the project (with the dummy app started):
254-
make lint
255-
# Run the test suite (with the dummy app started):
256-
make specs
257-
# Remove container and image:
258-
make cleanup
259-
# To try different versions of Ruby/Rails/ActiveAdmin edit docker-compose.yml
260-
# For more commands please check the Makefile
261-
```
262-
263-
2) Using Appraisal:
264-
265-
```sh
266-
export RAILS_ENV=development
267-
# Install dependencies:
268-
bin/appraisal
269-
# Run server (or any command):
270-
bin/appraisal rails s
271-
# Or with a specific configuration:
272-
bin/appraisal rails80-activeadmin rails s
273-
```
274-
275-
3) With a local setup:
276-
277-
```sh
278-
# Dev setup (set the required envs):
279-
source extra/dev_setup.sh
280-
# Install dependencies:
281-
bundle update
282-
# Run server (or any command):
283-
bin/rails s
284-
# To try different versions of Rails/ActiveAdmin edit extra/dev_setup.sh
285-
```
242+
For development information please check [this document](extra/development.md).
286243
287244
## Do you like it? Star it!
288245

Rakefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# frozen_string_literal: true
22

3+
begin
4+
require 'bundler/setup'
5+
rescue LoadError
6+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
7+
end
8+
9+
APP_RAKEFILE = File.expand_path("spec/dummy/Rakefile", __dir__)
10+
load 'rails/tasks/engine.rake'
11+
12+
load 'rails/tasks/statistics.rake'
13+
314
require 'bundler/gem_tasks'
415

516
begin

0 commit comments

Comments
 (0)