Skip to content

Commit c18ef4b

Browse files
committed
Use caching for faster builds
1 parent b559300 commit c18ef4b

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

‎Dockerfile‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,29 @@ deb http://archive.debian.org/debian-security stretch/updates main" > /etc/apt/s
66

77
# Disable the check for valid signatures on the archived repositories
88
# as the archived keys may not be up to date
9-
RUN apt-get -o Acquire::Check-Valid-Until=false update
10-
11-
# Install Python 2.7, pip, OpenJDK 8, libxml2-dev, libxslt-dev, and zlib1g-dev
12-
RUN apt-get install -y --allow-unauthenticated \
9+
RUN apt-get -o Acquire::Check-Valid-Until=false update && apt-get install -y --allow-unauthenticated \
1310
python2.7 \
1411
python-pip \
1512
openjdk-8-jdk \
1613
libxml2-dev \
1714
libxslt-dev \
1815
zlib1g-dev \
19-
&& apt-get clean \
20-
# Check if the python symlink exists and if it does, check if it points to python2.7
21-
# If it doesn't exist or it points to a different version of python, create the symlink
22-
&& ( [ ! -e /usr/bin/python ] || [ "$(readlink -f /usr/bin/python)" != "$(which python2.7)" ] ) && ln -sf $(which python2.7) /usr/bin/python || true
16+
&& apt-get clean
17+
18+
# Create a symbolic link for python if it doesn't exist or points to a different version
19+
RUN if [ ! -e /usr/bin/python ] || [ "$(readlink -f /usr/bin/python)" != "$(which python2.7)" ]; then ln -sf $(which python2.7) /usr/bin/python; fi
2320

2421
# Set the working directory in the container
2522
WORKDIR /usr/src/app
2623

27-
# Copy the current directory contents into the container at /usr/src/app
28-
COPY . .
24+
# Copy only the requirements.txt initially to leverage Docker cache
25+
COPY requirements.txt ./
2926

30-
# Install Jinja2 and lxml using pip
31-
RUN pip install --trusted-host pypi.python.org Jinja2 lxml
27+
# Install Python dependencies
28+
RUN pip install --no-cache-dir --trusted-host pypi.python.org -r requirements.txt
29+
30+
# Copy the rest of your application code
31+
COPY . .
3232

3333
# Make port 80 available to the world outside this container
3434
EXPOSE 80

0 commit comments

Comments
 (0)