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

Multistage Dockerfile #1021

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Multistage Dockerfile #1021

wants to merge 2 commits into from

Conversation

yksflip
Copy link
Member

@yksflip yksflip commented Aug 23, 2023

This PR

  • removes a db dependency for assets precompilation
  • adds rswag swaggerize swagger.yml generation and thatfore introduces the nulldb adapter (generate swagger.yml in dockerfile (rswag) #998)
  • remove Dockerfile-dev
  • unites dev and production image in one File using docker multi-stage

@yksflip yksflip added this to the 4.8 milestone Aug 23, 2023
@yksflip
Copy link
Member Author

yksflip commented Aug 25, 2023

any thoughts @paroga @wvengen ? :)

@wvengen
Copy link
Member

wvengen commented Aug 25, 2023

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
Copy link
Member

wvengen commented Aug 25, 2023

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
Copy link
Member Author

yksflip commented Aug 25, 2023

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 ...

@yksflip yksflip modified the milestones: 4.8, 4.8.1 Sep 4, 2023
@yksflip yksflip removed this from the 4.8.1 milestone Jan 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants