iridakos / duckrails

Development tool to mock API endpoints quickly and easily (docker image available)
https://github.com/iridakos/duckrails/wiki
MIT License
1.72k stars 108 forks source link

Docker absolute volume path and runtime error #58

Closed pun-ky closed 4 years ago

pun-ky commented 4 years ago
docker run --name=example_iridakos.duckrails.release-v2.1.5 -v=/Users/krystian.panek/Projects/gradle-aem-multi/duckrails:/opt/duckrails/db -p=8080:80 --rm iridakos/duckrails:release-v2.1.5
WARNING: Environment variable SECRET_KEY_BASE has not been set - Setting a random SECRET_KEY_BASE
rake aborted!
ActiveRecord::StatementInvalid: Could not find table 'mocks'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/sqlite3_adapter.rb:501:in `table_structure'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/sqlite3_adapter.rb:375:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/connection_adapters/schema_cache.rb:43:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/attributes.rb:93:in `columns'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/attributes.rb:98:in `columns_hash'
/opt/duckrails/vendor/bundle/ruby/2.4.0/gems/activerecord-4.2.8/lib/active_record/relation/delegation.rb:48:in `columns_hash'

but when I use just duckrails on the left side of volume it works.

docker run --name=example_iridakos.duckrails.release-v2.1.5 -v=duckrails:/opt/duckrails/db -p=8080:80 --rm iridakos/duckrails:release-v2.1.5

still when using absolute path or relative path, in both cases seems that volume is working / file duckrails/production.sqlite3 is created... so that seems that is is something wrong later on DuckRails runtime side.

this is blocking me in case of using Duckrails on Windows on which I need to support Docker Toolbox in which absolute volume paths usage is essential.

it would be nice to have it fixed :)

greetings, Krystian

pun-ky commented 4 years ago

also does not work when using Swarm :/

image

pun-ky commented 4 years ago

is there any chance to have it fixed within next days? sorry I have no Ruby knowledge to be able to fix it by myself :/

pun-ky commented 4 years ago

any volunteers to help with that? :)

ChristianHeimke commented 4 years ago

@pun-ky

I just stumbled over your issue, maybe you found the answer finally ;-) If not, this will maybe help you out:

You're calling docker with the wrong parameters:

# wrong
docker run --name=example_iridakos.duckrails.release-v2.1.5 -v=/Users/krystian.panek/Projects/gradle-aem-multi/duckrails:/opt/duckrails/db -p=8080:80 --rm iridakos/duckrails:release-v2.1.5

# right
docker run --name=example_iridakos.duckrails.release-v2.1.5 -v /Users/krystian.panek/Projects/gradle-aem-multi/duckrails:/opt/duckrails/db -p 8080:80 --rm iridakos/duckrails:release-v2.1.5

What's the diff? You shouldn't use = on short params like -p or -v. If you want to use it, you need to pass the double dash and the "full wording", e.g. --volume=... or --port=...

Maybe this will help :) I just tested the command from the docs:

docker run -p 8080:80 -v duckrails:/opt/duckrails/db iridakos/duckrails:latest

and it worked out of the box.

pun-ky commented 4 years ago

maybe... but I tested/repeated error when configuring container in compose file where these quotes don't matter. how about that? @ChristianHeimke https://github.com/iridakos/duckrails/issues/58#issuecomment-563985173

ChristianHeimke commented 4 years ago

yes, you're right.

I'm just guessing, but maybe it's related to the docker-entrypoint.sh, which will bootstrap the database and tables. maybe you can check out the difference of your file and the provided compose files:

I've tested the first one and it worked as expected. Maybe.. it is also related to the 2.1.5 version - I've not tested this specific one, just the lastest and the compose file with building the current source.

pun-ky commented 4 years ago

Good point, I will do that. @ChristianHeimke thx

pun-ky commented 4 years ago

I guess it could be somehow addressed by providing correct docker compose file so does not affect directly Duckrails app.