foodsoft on docker using the official image

Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

foodsoft on docker using the official image

Sven
Oh boy, this is a hard setup. Sorry.

I am following https://github.com/foodcoops/foodsoft/blob/master/doc/SETUP_PRODUCTION.md
using the official production docker image. I have mysql DB running and redis on localhost

According to that, I need to prepare an app_config.yml, and place it in `pwd`/config/app_config.yml. Check.
I need to set the env vars:
DATABASE_URL=mysql2://foodsoft:xxxxx@192.168.178.52:3306/foodsoftdb?encoding=utf8
REDIS_URL=redis://192.168.178.52:6379
SECRET_KEY_BASE=ZpIw6tz6AT8rVuTQxM1sIfh2vLoTx9
Check.

Then this fails:
$ docker run --name foodsoft_web --rm -e SECRET_KEY_BASE -e DATABASE_URL -e REDI
S_URL -e RAILS_FORCE_SSL=false   -v `pwd`/config/app_config.yml:/usr/src/app/con
fig/app_config.yml:ro foodcoops/foodsoft bundle exec rake db:setup              

Here is the trace:
`/nonexistent` is not a directory.                                              
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
foodsoftdb already exists                                                      
Loading app configuration from config/app_config.yml                            
rake aborted!                                                                  
Errno::EISDIR: Is a directory @ io_fread - /usr/src/app/config/app_config.yml  
/usr/src/app/lib/foodsoft_config.rb:63:in `read'                                
/usr/src/app/lib/foodsoft_config.rb:63:in `init'                                
/usr/src/app/config/initializers/01_load_app_config.rb:5:in `<top (required)>'  
[...]

I am supposed to create a directory /nonexistent?
The DB already exists, correct. I created it manually.
/usr/src/app/config/app_config.yml is NOT a dir, I run with bash as entrypoint and verifiied:
docker run -it --entrypoint /bin/bash foodcoops/foodsoft
nobody@830959cd5b59:/usr/src/app$ ls -l config
total 68
-rwxr-xr-x 1 root root 5831 Jan  7 16:54 app_config.yml
[...]

I also tried with a Windows path, and with the complete config directory bound from host
$ docker run --name foodsoft_web --net=host --rm -e SECRET_KEY_BASE -e DATABASE_URL -e REDIS_URL -e RAILS_FORCE_SSL=false   -v d:\sprev\Source\Repos\foodsoft\config:/usr/src/app/config:ro foodcoops/foodsoft bundle exec rake db:setup
`/nonexistent` is not a directory.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.rake aborted!
LoadError: cannot load such file -- /usr/src/app/config/application
/usr/src/app/Rakefile:4:in `require'
[...]
Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

wvengen
Administrator

Hi,

Thanks for sharing your experience. Sorry it's been a hard ride until now! Let's see.

The issue you're having here is that the app configuration cannot be found. Weirdly enough, the config file is mounted as a directory (instead of a file). In my local test with this, that didn't happen. Could it be related to a different Docker version and/or platform (Windows)? In any case, you could also build a derived Docker image with the configuration inside, like this example, run docker build and start the resulting image.

If you mount the complete directory, you need all the files in there (and not just app_config.yml). The error you're seeing when supplying a directory, is caused by these missing files.

Hope this helps a little. Please let us know how it goes.

Best,
- Willem

p.s. Be careful sharing SECRET_KEY_BASE, of course.


On 07-01-18 20:16, Sven [via foodsoft] wrote:
Oh boy, this is a hard setup. Sorry.

I am following https://github.com/foodcoops/foodsoft/blob/master/doc/SETUP_PRODUCTION.md
using the official production docker image. I have mysql DB running and redis on localhost

According to that, I need to prepare an app_config.yml, and place it in `pwd`/config/app_config.yml. Check.
I need to set the env vars:
[hidden email]
REDIS_URL=redis://192.168.178.52:6379
SECRET_KEY_BASE=ZpIw6tz6AT8rVuTQxM1sIfh2vLoTx9
Check.

Then this fails:
$ docker run --name foodsoft_web --rm -e SECRET_KEY_BASE -e DATABASE_URL -e REDI
S_URL -e RAILS_FORCE_SSL=false   -v `pwd`/config/app_config.yml:/usr/src/app/con
fig/app_config.yml:ro foodcoops/foodsoft bundle exec rake db:setup              

Here is the trace:
`/nonexistent` is not a directory.                                              
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.
foodsoftdb already exists                                                      
Loading app configuration from config/app_config.yml                            
rake aborted!                                                                  
Errno::EISDIR: Is a directory @ io_fread - /usr/src/app/config/app_config.yml  
/usr/src/app/lib/foodsoft_config.rb:63:in `read'                                
/usr/src/app/lib/foodsoft_config.rb:63:in `init'                                
/usr/src/app/config/initializers/01_load_app_config.rb:5:in `<top (required)>'  
[...]

I am supposed to create a directory /nonexistent?
The DB already exists, correct. I created it manually.
/usr/src/app/config/app_config.yml is NOT a dir, I run with bash as entrypoint and verifiied:
docker run -it --entrypoint /bin/bash foodcoops/foodsoft
nobody@830959cd5b59:/usr/src/app$ ls -l config
total 68
-rwxr-xr-x 1 root root 5831 Jan  7 16:54 app_config.yml
[...]

I also tried with a Windows path, and with the complete config directory bound from host
$ docker run --name foodsoft_web --net=host --rm -e SECRET_KEY_BASE -e DATABASE_URL -e REDIS_URL -e RAILS_FORCE_SSL=false   -v d:\sprev\Source\Repos\foodsoft\config:/usr/src/app/config:ro foodcoops/foodsoft bundle exec rake db:setup
`/nonexistent` is not a directory.
Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily.rake aborted!
LoadError: cannot load such file -- /usr/src/app/config/application
/usr/src/app/Rakefile:4:in `require'
[...]


If you reply to this email, your message will be added to the discussion below:
http://foodsoft.51229.x6.nabble.com/foodsoft-on-docker-using-the-official-image-tp1617.html
To start a new topic under foodsoft-dev, email [hidden email]
To unsubscribe from foodsoft-dev, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

noid
Hello,

we are members of a food cooperative trying to install foodsoft on our dedicated Debian server. Docker seems like the easiest way, but it's quite hard to find accurate information about how to configure the app.
After a lot of hours of unsuccesful trying and searching, we come here to find help.

We installed docker, ran docker pull, installed rvm, ruby on rails and redis. Now we are stuck at the configuration step :

- we can't find the application's root directory to put the app_config.yml fils inside. The command Rails.root returns "command not found"

- the command rake secret returns "no rakefile found" Where to crreat the rakefile and what to put inside ?

- can the config function with an external mysql instance (meaning not inside docker, but as a debian package)

- will we be able to access the docker/foodosft instance with classic HTTP request ?

After having succeeded we can create a detailed deployment tuto for unskilled users like us.


Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

wvengen
Administrator

Hi Noid,

Thanks your mail! I'm sorry to hear it wasn't so easy to get started with a production setup using Docker. But you're at the right place to ask for help (foodsoft-discuss would also be a good place).

This is Just a quick reply to check: did you consider reading https://github.com/foodcoops/foodsoft/blob/master/doc/SETUP_PRODUCTION.md ? As far as I understand, it explains what you'd like to do to get started. It doesn't explain how to start Redis and MySQL/MariaDB, though, but these should be relatively 'standard' to setup.

Kind regards,
- Willem

On 06-12-18 17:53, noid [via foodsoft] wrote:
Hello,

we are members of a food cooperative trying to install foodsoft on our dedicated Debian server. Docker seems like the easiest way, but it's quite hard to find accurate information about how to configure the app.
After a lot of hours of unsuccesful trying and searching, we come here to find help.

We installed docker, ran docker pull, installed rvm, ruby on rails and redis. Now we are stuck at the configuration step :

- we can't find the application's root directory to put the app_config.yml fils inside. The command Rails.root returns "command not found"

- the command rake secret returns "no rakefile found" Where to crreat the rakefile and what to put inside ?

- can the config function with an external mysql instance (meaning not inside docker, but as a debian package)

- will we be able to access the docker/foodosft instance with classic HTTP request ?

After having succeeded we can create a detailed deployment tuto for unskilled users like us.





If you reply to this email, your message will be added to the discussion below:
http://foodsoft.51229.x6.nabble.com/foodsoft-on-docker-using-the-official-image-tp1617p1846.html
To start a new topic under foodsoft-dev, email [hidden email]
To unsubscribe from foodsoft-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

noid
Hi, thank you for your quick answer.

Actually we (of course) have read and dissected the page you mention for several hours before posting. We also have googled every single question we asked on this topic, and compared our minds about it. We also tryed some docker tutos, and even installed other apps to check our knowledge.
Redis and mysql don't seem to be an obstacle, as we already know about creating new databases and all that stuff.

The problem is finding the directories paths :

- where to put the rakefile to have "rake secret" output a key ? The command outputs "no rakefile found". Eventually what to put inside the rakefile would help us.

- where to put app_config.yml ? (where is the 'pwd'/config mentioned above ?)

Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

wvengen
Administrator
Great :)
Now I see parts of the doc were written assuming you already have Foodsoft running locally. That, of course, is a strange assumption.
So you can just make your own 30-char random string instead of 'rake secret', or run the command _inside_ the container.
The app config you can download from https://github.com/foodcoops/foodsoft/blob/master/config/app_config.yml.SAMPLE and use the downloaded and adapted file path as the first part after -v.

Hope this helps a bit!

Cheers,
- Willem

On 7 December 2018 22:54:25 CET, "noid [via foodsoft]" <[hidden email]> wrote:
Hi, thank you for your quick answer.

Actually we (of course) have read and dissected the page you mention for several hours before posting. We also have googled every single question we asked on this topic, and compared our minds about it. We also tryed some docker tutos, and even installed other apps to check our knowledge.
Redis and mysql don't seem to be an obstacle, as we already know about creating new databases and all that stuff.

The problem is finding the directories paths :

- where to put the rakefile to have "rake secret" output a key ? The command outputs "no rakefile found". Eventually what to put inside the rakefile would help us.

- where to put app_config.yml ? (where is the 'pwd'/config mentioned above ?)




If you reply to this email, your message will be added to the discussion below:
http://foodsoft.51229.x6.nabble.com/foodsoft-on-docker-using-the-official-image-tp1617p1852.html
To start a new topic under foodsoft-dev, email [hidden email]
To unsubscribe from foodsoft-dev, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

noid
Ok thank you, this gives some useful details.

Now I'm trying to explore the containers filesystem to find the config directory where to put the app_config.yml.

~# docker container ls -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                   PORTS               NAMES
6beecd78476c        hello-world          "/hello"                 2 weeks ago         Exited (0) 2 weeks ago                       hungry_saha
fbc727be9b42        hello-world          "/hello"                 3 weeks ago         Exited (0) 3 weeks ago                       laughing_agnesi
1c3c62a1cbfc        foodcoops/foodsoft   "./docker-entrypoint…"   3 weeks ago         Up 3 seconds             3000/tcp            mystifying_heisenberg

~# docker exec -it 1c3c62a1cbfc bash
Error response from daemon: Container 1c3c62a1cbfc8dcdc2f22037c8f0aa82129fd00eae3a46a62caaedb0a573ee6d is not running

I started the container with

docker container start 1c3c62a1cbfc 

would this mean I should run it instead ? But I can't run it without the .yml file right ? I'm quite lost here...

By the more I don't understant the end of this sentence :
wvengen wrote
 The app config you can download from [link] and use the downloaded and adapted file path as the first part after -v.
Reply | Threaded
Open this post in threaded view
|

Re: foodsoft on docker using the official image

wvengen
Administrator
Great, it seems like you're slowly getting somewhere.

Now what you need is some more understanding of how docker containers work, and how to use volumes.

Firstly, you cannot change many things about a docker container that was already started: environment, volumes, used image, they are all fixed (see, for example this SO question about the environment), not even when you've stopped it and start it again. Normally, you'd just create a new container with the new options.

Secondly, you'll need to understand a bit how volumes work (see docker run's manpage). Docker run uses the -v parameter for this, with an argument in three parts: -v host-src:container-dest:options. While often volumes are used on directories, here we use it on just a single file: app_config.yml. The Foodsoft Docker container expects it in /usr/src/app/config/app_config.yml. Now if you download the configuration file to e.g. /var/local/foodsoft/app_config.yml, you could use the following with docker run: -v /var/local/foodsoft/app_config.yml:/usr/src/app/config/app_config.yml:ro

Does that bring you any further?

Kind regards,
- Willem

On 08-12-18 12:43, noid [via foodsoft] wrote:
Ok thank you, this gives some useful details.

Now I'm trying to explore the containers filesystem to find the config directory where to put the app_config.yml.

~# docker container ls -a
CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                   PORTS               NAMES
6beecd78476c        hello-world          "/hello"                 2 weeks ago         Exited (0) 2 weeks ago                       hungry_saha
fbc727be9b42        hello-world          "/hello"                 3 weeks ago         Exited (0) 3 weeks ago                       laughing_agnesi
1c3c62a1cbfc        foodcoops/foodsoft   "./docker-entrypoint…"   3 weeks ago         Up 3 seconds             3000/tcp            mystifying_heisenberg

~# docker exec -it 1c3c62a1cbfc bash
Error response from daemon: Container 1c3c62a1cbfc8dcdc2f22037c8f0aa82129fd00eae3a46a62caaedb0a573ee6d is not running

I started the container with

docker container start 1c3c62a1cbfc 

would this mean I should run it instead ? But I can't run it without the .yml file right ? I'm quite lost here...

By the more I don't understant the end of this sentence :
wvengen wrote
 The app config you can download from [link] and use the downloaded and adapted file path as the first part after -v.