-
Notifications
You must be signed in to change notification settings - Fork 3
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
Fixing more docker related stuff #141
Conversation
ctr26
commented
Aug 6, 2024
- Old changes broke the deployment for the main api image build.
- Issue was that the CI was quite specific, modified it to be more general
- Also make the building caching faster
https://github.com/ctr26/bia-integrator/actions/runs/10268180413 Passing build and push on my copy |
api/Dockerfile
Outdated
RUN poetry lock | ||
|
||
# Poetry lock command likely unnecessary as we are copying the whole project | ||
# For local development we only need to solve the lock once | ||
RUN poetry install |
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 think we also need to add poetry.lock to git if we do this. Also, even without resolving dependencies we would still pull all projects every time we build (e.g. on local). Can't we just re-add poetry.lock to git and keep the ADD shenanigans to make it go faster?
It's roughly the usecase at the bottom of this section (https://docs.docker.com/build/cache/#order-your-layers) in the docker docs
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.
If there's no lock file then poetry install will resolve when it installs.
We got rid of the lock file because it kept falling out of date when people make changes but didn't push lock changes.
There was a brief period of time where that was fixed with a pre-commit-hook but I don't think everyone adhered to installing that either?
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.
Also, git should be building with no-cache aswell to ensure it's all deterministic.
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.
Oh, you're right, forgot about the lockfile thing.
But can we keep the two-step add (lockfile/pyproject first, then install, then everything else on top of that)? That would make it so I don't always pull dependencies (even if they're resolved) when I rebuild on local as I'm changing code
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.
Ok, in my defence, I did not know you could run
poetry install
without providing any actual source files and that it then just magically symlinks it all later anyway when you dopoetry run
My original answer was that you need to do ADD before poetry install so that it has your source files to install. But it doesn't, I double checked.
Sorry for wasting time on my own baseless assumptions
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.
This was actually a warning I was always getting but ignoring because it's a warning! Since we just need the dependencies installed and run uvicorn from the project root, I think we could do --no-root
so bia-integrator-api
itself gets skipped, I didn't catch that / was just thinking of it as installing dependencies, not installing the project itself
Also, should we maybe keep the comment line # only add poetry.lock if it exists (building on local)
? It's there because the ADD below is weird, the poetry.lock*
is a workaround for 'add if it exists', because otherwise if it's missing Docker errors
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.
Add --no-root
Yeah so til you can run |
@liviuba ready to merge |
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.
LGTM!