Skip to content

feat: use chown during copy to reduce image size and build time #58

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
9 changes: 4 additions & 5 deletions template/python27-flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@ ENV PATH=$PATH:/home/app/.local/bin

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY --chown=app:app index.py .
COPY --chown=app:app requirements.txt .
USER root
RUN pip install -r requirements.txt
USER app

RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY function/requirements.txt .
COPY --chown=app:app function/requirements.txt .
RUN pip install --user -r requirements.txt

WORKDIR /home/app/

USER root
COPY function function
RUN chown -R app:app ./
COPY --chown=app:app function function
USER app

ENV fprocess="python index.py"
Expand Down
9 changes: 4 additions & 5 deletions template/python3-flask-debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ENV PATH=$PATH:/home/app/.local/bin

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY --chown=app:app index.py .
COPY --chown=app:app requirements.txt .

USER root
RUN pip install -r requirements.txt
Expand All @@ -31,14 +31,13 @@ USER app
RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY function/requirements.txt .
COPY --chown=app:app function/requirements.txt .
RUN pip install --user -r requirements.txt

#install function code
USER root

COPY function/ .
RUN chown -R app:app ../
COPY --chown=app:app function/ .

ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
Expand Down
9 changes: 4 additions & 5 deletions template/python3-flask/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ENV PATH=$PATH:/home/app/.local/bin

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY --chown=app:app index.py .
COPY --chown=app:app requirements.txt .

USER root
RUN pip install -r requirements.txt
Expand All @@ -31,14 +31,13 @@ USER app
RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY function/requirements.txt .
COPY --chown=app:app function/requirements.txt .
RUN pip install --user -r requirements.txt

#install function code
USER root

COPY function/ .
RUN chown -R app:app ../
COPY --chown=app:app function/ .

ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
Expand Down
9 changes: 4 additions & 5 deletions template/python3-http-debian/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,20 @@ ENV PATH=$PATH:/home/app/.local/bin

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY --chown=app:app index.py .
COPY --chown=app:app requirements.txt .
USER root
RUN pip install -r requirements.txt
USER app

RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY function/requirements.txt .
COPY --chown=app:app function/requirements.txt .
RUN pip install --user -r requirements.txt

USER root
COPY function/ .
RUN chown -R app:app ../
COPY --chown=app:app function/ .

ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
Expand Down
9 changes: 4 additions & 5 deletions template/python3-http/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ENV PATH=$PATH:/home/app/.local/bin

WORKDIR /home/app/

COPY index.py .
COPY requirements.txt .
COPY --chown=app:app index.py .
COPY --chown=app:app requirements.txt .
USER root
RUN pip install -r requirements.txt

Expand All @@ -30,13 +30,12 @@ USER app
RUN mkdir -p function
RUN touch ./function/__init__.py
WORKDIR /home/app/function/
COPY function/requirements.txt .
COPY --chown=app:app function/requirements.txt .
RUN pip install --user -r requirements.txt

# install function code
USER root
COPY function/ .
RUN chown -R app:app ../
COPY --chown=app:app function/ .

ARG TEST_COMMAND=tox
ARG TEST_ENABLED=true
Expand Down