Skip to content

Commit 728e3fa

Browse files
authored
Merge pull request #50 from blocknotes/dev/docker-setup
chore: Docker dev setup
2 parents 21fc69c + 9d891f0 commit 728e3fa

12 files changed

Lines changed: 242 additions & 33 deletions

File tree

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
UID=1000
2+
GID=1000

Gemfile

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,34 @@
22

33
source 'https://rubygems.org'
44

5-
gemspec
5+
if ENV["DEVEL"] == "1"
6+
gem 'rails', '~> 7.1.0'
67

7-
group :development, :test do
8-
gem 'puma'
9-
gem 'sassc'
10-
gem 'sprockets-rails'
11-
gem 'sqlite3'
8+
gem 'activeadmin', '~> 3.3'
9+
gem 'activeadmin_quill_editor', path: './'
10+
else
11+
gemspec
12+
end
1213

13-
# Testing
14-
gem 'capybara'
15-
gem 'cuprite'
16-
gem 'rspec_junit_formatter'
17-
gem 'rspec-rails'
18-
gem 'rspec-retry'
14+
gem 'puma'
15+
gem 'sassc'
16+
gem 'sprockets-rails'
17+
gem 'sqlite3'
1918

20-
# Linters
21-
gem 'fasterer'
22-
gem 'rubocop'
23-
gem 'rubocop-packaging'
24-
gem 'rubocop-performance'
25-
gem 'rubocop-rails'
26-
gem 'rubocop-rspec'
19+
# Testing
20+
gem 'capybara'
21+
gem 'cuprite'
22+
gem 'rspec_junit_formatter'
23+
gem 'rspec-rails'
24+
gem 'rspec-retry'
2725

28-
# Tools
29-
gem 'pry-rails'
30-
end
26+
# Linters
27+
gem 'fasterer'
28+
gem 'rubocop'
29+
gem 'rubocop-packaging'
30+
gem 'rubocop-performance'
31+
gem 'rubocop-rails'
32+
gem 'rubocop-rspec'
33+
34+
# Tools
35+
gem 'pry-rails'

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
help:
2+
@echo "Main targets: up / down / console / shell"
3+
4+
# Docker commands
5+
down:
6+
docker compose down
7+
8+
up:
9+
docker compose up
10+
11+
attach:
12+
docker compose attach app
13+
14+
up_attach:
15+
docker compose up -d && docker compose attach app
16+
17+
cleanup:
18+
docker container rm -f activeadmin_quill_editor_app && docker image rm -f activeadmin_quill_editor-app
19+
20+
# Rails specific commands
21+
console:
22+
docker compose exec -e "PAGER=more" app bin/rails console
23+
24+
routes:
25+
docker compose exec app bin/rails routes
26+
27+
specs:
28+
docker compose exec app bin/rspec --fail-fast
29+
30+
# Other commands
31+
bundle:
32+
docker compose exec app bundle
33+
34+
shell:
35+
docker compose exec -e "PAGER=more" app bash
36+
37+
lint:
38+
docker compose exec app bin/rubocop

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,21 +101,33 @@ Consider that this is just a basic example: images are uploaded as soon as they
101101
the *upload_admin_post_path*) and it doesn't provide a way to remove images (just deleting them from
102102
the editor will not destroy them, you'll need to implement a purge logic for that).
103103

104-
## Changelog
104+
## Development
105105

106-
The changelog is available [here](CHANGELOG.md).
106+
Project created by [Mattia Roccoberton](http://blocknot.es), thanks also to the good guys that opened issues and pull requests from time to time.
107+
108+
A Docker dev setup is provided if you like to work with it:
109+
110+
```sh
111+
# Run rails server on the dummy app (=> http://localhost:3000 to access to ActiveAdmin):
112+
make up
113+
# Enter in a console of the dummy app after it has been started:
114+
make console
115+
# Enter in a shell of the dummy app after it has been started:
116+
make shell
117+
# Run the linter on the project:
118+
make lint
119+
# Remove container and image after stopping the app:
120+
make cleanup
121+
```
122+
123+
For more commands please check the [Makefile](Makefile).
107124

108125
## Do you like it? Star it!
109126

110127
If you use this component just star it. A developer is more motivated to improve a project when there is some interest. My other [Active Admin components](https://github.com/blocknotes?utf8=✓&tab=repositories&q=activeadmin&type=source).
111128

112129
Or consider offering me a coffee, it's a small thing but it is greatly appreciated: [about me](https://www.blocknot.es/about-me).
113130

114-
## Contributors
115-
116-
- [Mattia Roccoberton](http://blocknot.es): author
117-
- The good guys that opened issues and pull requests from time to time
118-
119131
## License
120132

121133
The gem is available as open-source under the terms of the [MIT](LICENSE.txt).

activeadmin_quill_editor.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
2525
spec.files = Dir['{app,lib}/**/*', 'LICENSE.txt', 'Rakefile', 'README.md']
2626
spec.require_paths = ['lib']
2727

28-
spec.add_runtime_dependency 'activeadmin', '>= 2.9', '< 4'
28+
spec.add_runtime_dependency 'activeadmin', '>= 2.9', '< 4' # rubocop:disable Gemspec/AddRuntimeDependency
2929

3030
spec.add_development_dependency 'appraisal', '~> 2.4' # rubocop:disable Gemspec/DevelopmentDependencies
3131
end

docker-compose.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
services:
2+
app:
3+
container_name: 'activeadmin_quill_editor_app'
4+
build:
5+
context: .
6+
dockerfile: ./extra/Dockerfile
7+
args:
8+
RUBY_VERSION: 3.3.6
9+
UID: ${UID}
10+
user: "${UID}:${GID}"
11+
ports:
12+
- '3000:3000'
13+
working_dir: '/app'
14+
volumes:
15+
- '.:/app'
16+
stdin_open: true
17+
tty: true
18+
entrypoint:
19+
- /bin/sh
20+
- ./extra/entrypoint.sh

extra/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
ARG RUBY_VERSION=3
2+
FROM ruby:${RUBY_VERSION}
3+
4+
ARG UID
5+
6+
ENV DEVEL=1
7+
ENV LANG=C.UTF-8
8+
ENV RAILS_ENV=development
9+
10+
RUN apt-get update -qq
11+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yqq --no-install-recommends build-essential chromium libyaml-dev
12+
13+
RUN gem install bundler
14+
RUN echo 'gem: --no-document' > /etc/gemrc
15+
16+
COPY . /app
17+
18+
RUN mkdir -p /home/app
19+
RUN useradd -u ${UID} --shell /bin/bash app
20+
RUN chown -R app /usr/local/bundle
21+
RUN chown -R app:app /home/app && chown -R app:app /app
22+
23+
USER ${UID}
24+
25+
WORKDIR /app
26+
RUN bundle update

extra/entrypoint.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cd spec/dummy && bundle exec rails db:migrate
2+
cd - && rm -f spec/dummy/tmp/pids/server.pid && bundle exec rails s -b 0.0.0.0

spec/dummy/config/database.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ default: &default
33
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
44
timeout: 5000
55

6+
development:
7+
<<: *default
8+
database: db/development.sqlite3
9+
schema_dump: schema_development.rb
10+
611
test:
712
<<: *default
813
database: db/test.sqlite3

spec/dummy/config/environments/development.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
end
3030

3131
# Store uploaded files on the local file system (see config/storage.yml for options).
32-
# config.active_storage.service = :local
32+
config.active_storage.service = :local
3333

3434
# # Don't care if the mailer can't send.
3535
# config.action_mailer.raise_delivery_errors = false

0 commit comments

Comments
 (0)