foodsoft on docker using the official image

Looks like I speaked too fast :

I ran

docker run --name foodsoft_prod -p 3000 -e SECRET_KEY_BASE='mYunBreAkaBleKEY15476147654145' -e DATABASE_URL='mysql2://root:foodsoft@172.17.0.2/foodsoftdb?encoding=utf8' -e REDIS_URL='redis://vmjin.tetaneutral.net:6379' -e RAILS_FORCE_SSL=false   -v /var/www/app_config.yml:/usr/src/app/config/app_config.yml:ro   foodcoops/foodsoft

and I now have an error with authentification, yet I made the proper basic configuration with mysql (creating a new database, putting a root password, flush privileges…) :

=> Booting Thin
=> Rails 4.2.10 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Loading app configuration from config/app_config.yml
Exiting
/usr/src/app/vendor/bundle/ruby/2.3.0/gems/mysql2-0.4.10/lib/mysql2/client.rb:89:in `connect': Authentication plugin 'caching_sha2_password' cannot be loaded: /usr/lib/x86_64-linux-gnu/mariadb18/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory (Mysql2::Error)

I notice there is mariadb library file searched in usr/lib, should I install mariadb as well ?

I tried to run this inside the container without any success, although mysql returned ‘Query Ok’

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'psswdformyfooddb';

Did you search for it on the internet?

It looks like the version of mysql/mariadb you’re using has a new default password mechanism that the library installed in Foodsoft doesn’t support.
For now you’d better use the mysql_native_password password encryption method when setting the user password in mysql/mariadb. In a future version of the Foodsoft Docker image, we’d better update the mysql2 gem/package so that it uses a later version.

  • Willem

Yes, I found the reason of the issue in a few minutes and tried to use mysql_native_password as indicated above (I edited my post so if you read from your emails you probably did not see it).

I already tryed the workaround indicated in this StackOverflow thread (using docker exec) and mysql returned ‘Query OK’, but running the command ‘docker run’ after this was unsuccesfull.
In case you read from your emails here is the command I entered :

 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'psswdformyfooddb';

Hello, sorry for the inconvenience but I have a new issue…

I managed to connect to mysql using an older version of the container (v5.5)
Now it is redis that outputs an issue. As far as I understand, it may be related to how foodsoft tries to connect to redis server :

the run command below

docker run --name foodsoft_prod -p 3000 -e SECRET_KEY_BASE='mYunBreAkaBleKEY15476147654145' -e DATABASE_URL='mysql2://root:foodsoft@172.17.0.2/foodsoftdb?encoding=utf8' -e REDIS_URL='redis://my.host.net:6379' -e RAILS_FORCE_SSL=false   -v /var/www/app_config.yml:/usr/src/app/config/app_config.yml:ro   foodcoops/foodsoft

and the output

`/nonexistent` is not a directory.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
=> Booting Thin
=> Rails 4.2.10 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Loading app configuration from config/app_config.yml
Exiting
/usr/src/app/vendor/bundle/ruby/2.3.0/gems/resque-1.27.4/lib/resque.rb:116:in `redis=': undefined method `connect' for Redis:Class (NoMethodError)
	from /usr/src/app/config/initializers/resque.rb:2:in `<top (required)>'
	from /usr/src/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `load'
	from /usr/src/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:268:in `block in load'
	from /usr/src/app/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/dependencies.rb:240:in `load_dependency'

I tried several versions of redis (latest, 4.0.14 and 3.0.5) and the issue is still the same.

Ok I finally got it running without redis. As redis is optionnal, I just erased the environment variable describing my redis server and th container now runs :

 docker container ls -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                    PORTS                     NAMES
7b75efc592ef        foodcoops/foodsoft   "./docker-entrypoint…"   9 minutes ago       Up 9 minutes              0.0.0.0:32787->3000/tcp   foodsoft_prod
569f0715687c        mysql:5.5            "docker-entrypoint.s…"   23 hours ago        Up 23 hours               3306/tcp                  foodsoft-mysql
1c3c62a1cbfc        foodcoops/foodsoft   "./docker-entrypoint…"   4 months ago        Exited (1) 3 months ago                             mystifying_heisenberg

I can’t access it though. Port 3000 shows a classic “connection failed” error and port 32787 returns a “500 Internal Server Error”.
Would I have missed a configuration step ? I double checked my app_config.yml but the options provided in it don’t seem to contain any critical information.

EDIT : I indeed missed two steps : populating the database and running the worker. The database step went good, but running the worker without redis fails and specifying a redis-server instance gives that ‘NoMethod’ error. As it is an error related with a bersion of redis that is no longer disponible on docker, I don’t have any idea of how to fix it
https://github.com/resque/resque/issues/1614

Great you’re kind of getting started. Looking at the docker logs would probably tell you what’s the matter this time.
Redis is used for sending notifications to users, so that may not work without (you can also set Resque.inline = true in an initializer to do that inline, but that won’t work with many users).

Eventually, I’d really advise using docker-compose, where you can specify dependencies and environment variables for multiple containers. You may take inspiration from the foodcoops.net setup.

It works thank you very much for your help !

the foodcoop GASET from Toulouse is back to foodsoft :slight_smile:

We will now import our database in this new version and go on helping the project with translations and <ahref=“https://gaset.tetaneutral.net/doc/index.html”>documentation.