Skip to content

quix init could generate more developer-friendly dockerfiles. #41

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

Closed
krisajenkins opened this issue Jun 21, 2024 · 1 comment
Closed
Labels
enhancement New feature or request

Comments

@krisajenkins
Copy link

krisajenkins commented Jun 21, 2024

The dockerfile that quix init puts into each app directory is short, and that's good. But it also does a complete re-install of all the python dependencies on every rebuild, and that's bad.

A dockerfile like this separates out the pip install -r requirements.txt stage so that it can be cached. That makes rebuilds vastly faster:

# Dependency-building stage.
FROM python:3.11.1-slim-buster AS build

ENV DEBIAN_FRONTEND="noninteractive"
ENV PYTHONUNBUFFERED=1
ENV PYTHONIOENCODING=UTF-8

WORKDIR /app
RUN python3 -m venv env
ENV PATH="env/bin:$PATH"

COPY requirements.txt .
RUN python3 -m pip install -r requirements.txt

# Runtime stage.
FROM python:3.11.1-slim-buster AS runtime

WORKDIR /app
COPY --from=build /app/env /app/env
ENV PATH="env/bin:$PATH"

COPY . .

ENTRYPOINT ["env/bin/python3", "main.py"]

The cost is a longer dockerfile, but since it's autogenerated anyway, that's not too big a price to pay for faster redeployments.

@krisajenkins
Copy link
Author

See also: quixio/template-hello-quix#14

@luisquix luisquix added the enhancement New feature or request label Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants