-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dockerfiles] Use docker buildkit caching in dockerfiles
- Loading branch information
Showing
3 changed files
with
50 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,30 @@ | ||
# syntax = docker/dockerfile:1.2 | ||
FROM phusion/baseimage:focal-1.0.0 | ||
|
||
RUN adduser --disabled-password --gecos "" app_user | ||
RUN echo "alias python=python3" > /home/app_user/.bashrc | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install software-properties-common \ | ||
python3-dev \ | ||
python3-pip | ||
python3-dev \ | ||
python3-pip && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN pip3 install --upgrade pip | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install --upgrade pip | ||
|
||
# Create src dir | ||
ENV PROJECT_DIR /py-pdf-parser | ||
|
||
WORKDIR $PROJECT_DIR | ||
ADD ./ $PROJECT_DIR | ||
|
||
# Add imagemagick policy | ||
ADD ./imagemagick_policy.xml /etc/ImageMagick-6/policy.xml | ||
|
||
# Clean up APT when done. | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
# Install requirements | ||
ADD ./setup.py $PROJECT_DIR/setup.py | ||
ADD ./README.md $PROJECT_DIR/README.md | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR | ||
|
||
# Copy code, chown and switch user | ||
ADD ./ $PROJECT_DIR | ||
RUN chown -R app_user: $PROJECT_DIR | ||
|
||
RUN pip3 install $PROJECT_DIR | ||
|
||
USER app_user | ||
|
||
RUN echo "alias python=python3" > /home/app_user/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
# syntax = docker/dockerfile:1.2 | ||
FROM phusion/baseimage:focal-1.0.0 | ||
|
||
RUN adduser --disabled-password --gecos "" app_user | ||
RUN echo "alias python=python3" > /home/app_user/.bashrc | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install software-properties-common \ | ||
python3-dev \ | ||
python3-pip \ | ||
libmagickwand-dev \ | ||
mesa-utils \ | ||
libxkbcommon-x11-dev | ||
python3-dev \ | ||
python3-pip \ | ||
libmagickwand-dev \ | ||
mesa-utils \ | ||
libxkbcommon-x11-dev && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN pip3 install --upgrade pip | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install --upgrade pip | ||
|
||
# Create src dir | ||
ENV PROJECT_DIR /py-pdf-parser | ||
|
||
WORKDIR $PROJECT_DIR | ||
ADD ./ $PROJECT_DIR | ||
|
||
# Add imagemagick policy | ||
ADD ./imagemagick_policy.xml /etc/ImageMagick-6/policy.xml | ||
|
||
# Clean up APT when done. | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
# Install requirements | ||
ADD ./setup.py $PROJECT_DIR/setup.py | ||
ADD ./README.md $PROJECT_DIR/README.md | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[dev] | ||
|
||
# Copy code, chown and switch user | ||
ADD ./ $PROJECT_DIR | ||
RUN chown -R app_user: $PROJECT_DIR | ||
|
||
RUN pip3 install -e $PROJECT_DIR[dev] | ||
|
||
USER app_user | ||
|
||
RUN echo "alias python=python3" > /home/app_user/.bashrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
# syntax = docker/dockerfile:1.2 | ||
FROM phusion/baseimage:focal-1.0.0 | ||
|
||
RUN adduser --disabled-password --gecos "" app_user | ||
RUN echo "alias python=python3" > /home/app_user/.bashrc | ||
|
||
RUN apt-get update && \ | ||
apt-get -y install software-properties-common \ | ||
python3-dev \ | ||
python3-pip \ | ||
libmagickwand-dev \ | ||
xvfb | ||
python3-dev \ | ||
python3-pip \ | ||
libmagickwand-dev \ | ||
mesa-utils \ | ||
libxkbcommon-x11-dev \ | ||
xvfb && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN pip3 install --upgrade pip | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install --upgrade pip | ||
|
||
# Create src dir | ||
ENV PROJECT_DIR /py-pdf-parser | ||
|
||
WORKDIR $PROJECT_DIR | ||
COPY ./README.md $PROJECT_DIR/README.md | ||
COPY ./setup.py $PROJECT_DIR/setup.py | ||
|
||
# Clean up APT when done. | ||
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
RUN chown -R app_user: $PROJECT_DIR | ||
# Add imagemagick policy | ||
ADD ./imagemagick_policy.xml /etc/ImageMagick-6/policy.xml | ||
|
||
RUN pip3 install -e $PROJECT_DIR[dev] | ||
RUN pip3 install -e $PROJECT_DIR[test] | ||
# Install requirements | ||
ADD ./setup.py $PROJECT_DIR/setup.py | ||
ADD ./README.md $PROJECT_DIR/README.md | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[dev] | ||
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -e $PROJECT_DIR[test] | ||
|
||
COPY ./imagemagick_policy.xml /etc/ImageMagick-6/policy.xml | ||
COPY ./ $PROJECT_DIR | ||
# Copy code, chown and switch user | ||
ADD ./ $PROJECT_DIR | ||
RUN chown -R app_user: $PROJECT_DIR | ||
|
||
USER app_user | ||
|
||
RUN echo "alias python=python3" > /home/app_user/.bashrc |