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

Dockerfile improvements #1655

Merged
merged 4 commits into from
Mar 1, 2023
Merged

Conversation

NigelRook
Copy link
Contributor

No description provided.

NigelRook and others added 4 commits February 27, 2023 23:31
- 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
Copy link
Contributor

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 . .
Copy link
Contributor

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

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

@mion00 mion00 mentioned this pull request Mar 1, 2023

# Fetch requirements
COPY requirements.txt .
RUN pip install -r requirements.txt
Copy link
Contributor

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.

@acockburn
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants