-
Notifications
You must be signed in to change notification settings - Fork 9
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
Refactor: Multi-stage Docker build for app image #2392
Conversation
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
f4d11a6
to
1d65aa5
Compare
1d65aa5
to
a85b2ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I followed all the steps and this worked for me 👍 Just to make sure, I also ran python -m setuptools_scm
inside the container to do another confirmation of the version string and got 2024.9.99
✅
Reviewing this |
I'm getting an error when trying to rebuild the app image (step 3)
I'll look into this more edit: the issue I'm seeing might be from an issue with Docker for Windows... see docker/for-win#14083. I think it's been a while since I've rebuilt my app image, so it could be that this has been broken for me for a while and I just hadn't run into it yet. |
@angela-tran are you seeing the same issue with the |
Hmm good point. I am not seeing it... |
Moving back to Draft, we'll hold off on this until Slush. |
I have a Windows laptop that I recently updated for other home projects and I thought about trying this PR on it. I was able to build the image (step 3) but had some trouble (unrelated to this PR) running the container due to line endings (even though we have a |
Trying this again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixes issue with version calculation from a dirty git index during Docker build time / pip install time there's no reason to have the .git directory in the app image, same with all the extra files, tests, .devcontainer, etc. same approach as eligibility-server's Dockerfile
since it is no longer available in the base app image
maintainers, more project urls
a85b2ee
to
34ecd8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lalver1 and/or @machikoyasuda please review on a Mac environment. |
The testing steps worked for me 👍 but I noticed that inside the container, the command Running |
Can you say more about the concern here? I think we can definitely install this tool in the image, especially if it was working/available before. But I'm not seeing where this is actually needed within a running container? During Docker build time, in the first phase, Or am I missing something? |
Good callout. I think it is expected to not have The first stage is for building a The second stage copies the build artifact from There are more details if you're interested here: https://docs.docker.com/build/building/multi-stage/ |
Ah that makes sense, thanks @thekaveman and @angela-tran ! I agree, we don't need |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed on a Mac and it works 👍
Note @lalver1 that |
I was confused @thekaveman, now I'm sure that for the first review I ran benefits/.devcontainer/Dockerfile Line 10 in 1b92352
I just tried it again to check and sure enough, it works and shows the correct version number. Thanks for clearing it up! |
Closes #2389.
Fixes the issue with the dynamic version calculation being incorrect, because of a dirty git index during Docker build time / pip install time.
There's no reason to have the .git directory in the app image, same with all the extra files, tests, .devcontainer, etc.
Uses the approach from eligibility-server: https://github.com/cal-itp/eligibility-server/blob/main/Dockerfile
How to test
git status
)git tag -a 2024.10.999
docker compose build --no-cache client
to rebuild the app imagedocker compose up -d client
to start a new app containerdocker compose exec -ti client /bin/bash
to connect to running containerpython manage.py shell
to enter a Django shell with settings loadedimport benefits; print(benefits.VERSION)
✅bin/build.sh
to rebuild the devcontainer