-
Notifications
You must be signed in to change notification settings - Fork 419
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
Dockerfile improvements #1655
Dockerfile improvements #1655
Conversation
- Reduced image size to ~285Mb - Now compatible with alpine's py3-* packages
Preserves backwards compatibility
# Install additional packages | ||
RUN apk add --no-cache curl | ||
# Copy appdaemon into image | ||
COPY . . | ||
|
||
# Start script | ||
RUN chmod +x /usr/src/app/dockerStart.sh |
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 would skip this step by simply making the file executable directly in the repo
# Install additional packages | ||
RUN apk add --no-cache curl | ||
# Copy appdaemon into image | ||
COPY . . |
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.
We should copy only the files related to the application, instead of the whole repository. That way we have a better chance of re-using the Docker layer cache, without introducing unrelated changed files in the image.
WORKDIR /build | ||
|
||
# Install dependencies | ||
RUN apk add --no-cache git python3 python3-dev py3-pip py3-wheel build-base gcc libffi-dev openssl-dev musl-dev cargo |
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 suggest using the RUN --mount type=cache
command to optimize the apk cache, as documented here:
https://docs.docker.com/build/cache/#keep-layers-small
|
||
# Fetch requirements | ||
COPY requirements.txt . | ||
RUN pip install -r requirements.txt |
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.
Since we have moved from a requirements.txt
to a pyproject.toml
to describe the dependencies, these step no longer work.
I propose #1669 as an alternative.
Thanks both of you - it's about time Docker got a little love. We will optimize the image per Nigel's original intentions and add in Carlo's fixes. |
No description provided.