foodcoops / foodsoft

Web-based software to manage a non-profit food coop (product catalog, ordering, accounting, job scheduling).
https://foodcoops.net/
Other
326 stars 146 forks source link

Multistage Dockerfile #1021

Open yksflip opened 1 year ago

yksflip commented 1 year ago

This PR

yksflip commented 1 year ago

any thoughts @paroga @wvengen ? :)

wvengen commented 1 year ago

Awesome! Not sure though about merging the production and dev Dockerfile. I think the Dockerfile is complex enough without it. And does it mean by doing docker build -t foodsoft . builds both the development and production image? Also, when building the swagger file, I would expect it to have RAILS_ENV=production, e.g. routes might be affected by the environment.

wvengen commented 1 year ago

p.s. in other projects, I've used a dummy DATABASE_URL without even needing the nulldb adapter - but I guess it's cleaner

yksflip commented 1 year ago

thanks for your comments! Hm yeah I see what you mean. I thought it could reduce complexity and I liked the multi-stage idea, but in the end everything blew up a bit.

You can choose what target to build with e.g. docker build --target development, but the production stage requires the development as it copies the swagger.yml file. We could generate the swagger.yml in the production stage, but that would require the rswag gem in the prod group.

Good point about the RAILS_ENV, I think I used test as the rswag-specs gem is not part of the production group. Afaic the swagger file is generated by the definitions of the spec/requests/ tests. But I can double check if it makes any differences.

What a hack with the DATABASE_URL, I didn't know. I think I'd even prefer that than having another dependency ...