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

RAILS_ENV=development supposed to work? #298

Open
cvx35isl opened this issue Aug 15, 2023 · 5 comments
Open

RAILS_ENV=development supposed to work? #298

cvx35isl opened this issue Aug 15, 2023 · 5 comments

Comments

@cvx35isl
Copy link

has anyone tried this? I wanna use it for developing a plugin.

so I wrote me a container-compose.yaml file that puts the plugins' source tree right into /usr/src/redmine/plugins/myplugin of the container (plus a persistent sqlite file for convenience) and this works satisfactory:

version: '4'

services:

  myplugin-devel:
    container_name: myplugin-devel
    image: docker.io/redmine:5-alpine
    environment:
      RAILS_ENV: production
    ports:
      - 8080:3000
    volumes:
      - .:/usr/src/redmine/plugins/myplugin:rw,z
      - ./sqlite:/usr/src/redmine/sqlite:rw

volumes:
  myplugin:
  sqlite:

for better workability I want to run with RAILS_ENV: development but it fails to start with:

$ podman-compose up
podman-compose version: 1.0.6
['podman', '--version', '']
using podman version: 4.6.0
** excluding:  set()
['podman', 'ps', '--filter', 'label=io.podman.compose.project=myplugin', '-a', '--format', '{{ index .Labels "io.podman.compose.config-hash"}}']
['podman', 'network', 'exists', 'myplugin_default']
podman create --name=myplugin-devel --label io.podman.compose.config-hash=8a989d8b735c503b473f825181e61db6b807c6a150426f375c6e45239587833f --label io.podman.compose.project=myplugin --label io.podman.compose.version=1.0.6 --label [email protected] --label com.docker.compose.project=myplugin --label com.docker.compose.project.working_dir=/home/me/WORK/myplugin --label com.docker.compose.project.config_files=container-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=myplugin-devel -e RAILS_ENV=development -v /home/me/WORK/myplugin:/usr/src/redmine/plugins/myplugin:z,rw -v /home/me/WORK/myplugin/sqlite:/usr/src/redmine/sqlite:rw --net myplugin_default --network-alias myplugin-devel -p 8080:3000 docker.io/redmine:5-alpine
510972f950097c2c0c131f7efe9bff99a24c28672cba0a3d7c4009eabca3ec18
exit code: 0
podman start -a myplugin-devel

warning: missing REDMINE_DB_MYSQL, REDMINE_DB_POSTGRES, or REDMINE_DB_SQLSERVER environment variables

*** Using sqlite3 as fallback. ***

Your Gemfile lists the gem puma (>= 0) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
[myplugin-devel] | The Gemfile's dependencies are satisfied
rake aborted!
LoadError: cannot load such file -- listen
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/evented_file_update_checker.rb:6:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/src/redmine/config/environments/development.rb:58:in `block in <top (required)>'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/railtie.rb:234:in `instance_eval'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/railtie.rb:234:in `configure'
/usr/src/redmine/config/environments/development.rb:5:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/engine.rb:571:in `block (2 levels) in <class:Engine>'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/engine.rb:570:in `each'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/engine.rb:570:in `block in <class:Engine>'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `instance_exec'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:32:in `run'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:50:in `each'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:50:in `tsort_each_child'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/initializable.rb:60:in `run_initializers'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:391:in `initialize!'
/usr/src/redmine/config/environment.rb:16:in `<top (required)>'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `block in require'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:299:in `load_dependency'
/usr/local/bundle/gems/activesupport-6.1.7.2/lib/active_support/dependencies.rb:332:in `require'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:367:in `require_environment!'
/usr/local/bundle/gems/railties-6.1.7.2/lib/rails/application.rb:533:in `block in run_tasks_blocks'
Tasks: TOP => db:migrate => db:load_config => environment
(See full trace by running task with --trace)
exit code: 1

the line LoadError: cannot load such file -- listen I do not comprehend. It somehow looks as something is just missing for the development mode.

A clue anyone?

@cvx35isl
Copy link
Author

its because of this block in Gemfile:

group :development do
  gem 'listen', '~> 3.3'
  gem "yard"
end

these gems are not installed in the image and can't be installed by bundle install at start cause compilers and stuff are missing.

@tianon
Copy link
Member

tianon commented Dec 11, 2023

I don't think it's recommended to run Redmine in "development" mode (which is why we haven't explicitly supported doing so).

@cvx35isl
Copy link
Author

i wanna do this to develop a plugin and to test+fix it against the various major release trees of Redmine

also, with my self-cooked image, I found the ability quite useful when investigating problems with production instances: just flip RAILS_ENV and get to see much more ... on own risk, of course.

@tianon
Copy link
Member

tianon commented Dec 12, 2023

Ah, so the best answer might be a really short Dockerfile (perhaps even putting FROM / Redmine version inside an ARG so you can swap it at build time?) that sets RAILS_ENV=development and does the bundle install in the same way as our original Dockerfile so it works correctly inside the container too?

@cvx35isl
Copy link
Author

cvx35isl commented Dec 14, 2023

better: and ENV so it can be be changed at runtime.

background: I run my instances with Kubernetes and when some user runs into a problem the most easy and quick thing to do is kubectl edit deploy/my-instance which will pop up the editor with the yaml of that instance -> I flip the variable and save, Kubernetes will restart that pod and I start observing logs (kubectl logs deploy/my-instance -f), while the user just reloads his browser page and does what he did again ...

this helped me finding many problems and also gives logs with enough detail for useful bug reports at the same time, while switching back to "production" is just as easy. In my experience its almost always problems coming from instance specific settings and data - cumbersome to reproduce with stock setup.

afaik your current Dockerfile is just missing a few dependencies in Gemfile to make this work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants