From c7fd215c04e6c435fc98c3fd45d45dcab002436a Mon Sep 17 00:00:00 2001 From: Ike Johnson-Woods Date: Tue, 28 May 2024 21:08:23 +0800 Subject: [PATCH 1/4] Move COPY command down the file By moving the COPY command under the apk command, the package installation no longer runs on every change --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5f7c1bb..d1ca34d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,6 @@ ARG TZ='UTC' ENV DEFAULT_TZ ${TZ} -COPY . /opt/github-team-sync -WORKDIR /opt/github-team-sync - RUN apk add --no-cache \ libxml2-dev \ libxslt-dev \ @@ -26,6 +23,9 @@ RUN apk add --no-cache \ # Fix the warning where no timezone is specified RUN cp /usr/share/zoneinfo/${DEFAULT_TZ} /etc/localtime +COPY . /opt/github-team-sync +WORKDIR /opt/github-team-sync + RUN pip install --no-cache-dir --upgrade pipenv RUN pipenv install From 8a96ca51a27d634bc89d3502c2c21f13b5fc5236 Mon Sep 17 00:00:00 2001 From: Ike Johnson-Woods Date: Tue, 28 May 2024 21:15:07 +0800 Subject: [PATCH 2/4] Re-arrange pipenv setup steps We should install pipenv before copying any files, as its outcome won't be changed by any file updates. Additionally, copying only the pipfiles in then running pipenv install before copying the rest of the project helps prevent rebuilds. --- Dockerfile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d1ca34d..0f634f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,11 +23,13 @@ RUN apk add --no-cache \ # Fix the warning where no timezone is specified RUN cp /usr/share/zoneinfo/${DEFAULT_TZ} /etc/localtime -COPY . /opt/github-team-sync -WORKDIR /opt/github-team-sync - RUN pip install --no-cache-dir --upgrade pipenv +WORKDIR /opt/github-team-sync +COPY Pipfile Pipfile.lock . + RUN pipenv install +COPY . /opt/github-team-sync + CMD pipenv run flask run From c0d6bf0e02151bdcfef055c2f28b5cdb81120c1a Mon Sep 17 00:00:00 2001 From: Ike Johnson-Woods Date: Wed, 14 Aug 2024 19:30:50 +0800 Subject: [PATCH 3/4] Fix warnings from buildx --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0f634f1..2240da6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ LABEL maintainer="GitHub Services " ARG TZ='UTC' -ENV DEFAULT_TZ ${TZ} +ENV DEFAULT_TZ=${TZ} RUN apk add --no-cache \ libxml2-dev \ @@ -32,4 +32,4 @@ RUN pipenv install COPY . /opt/github-team-sync -CMD pipenv run flask run +CMD ["pipenv", "run", "flask", "run"] From 117b4058d3fdfc711f96489b381ba3b72d89893f Mon Sep 17 00:00:00 2001 From: Ike Johnson-Woods Date: Wed, 14 Aug 2024 20:01:59 +0800 Subject: [PATCH 4/4] Don't install build libraries pip pulls down pre-compiled versions of all the required packages, so we don't need to build anything locally. --- Dockerfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2240da6..ff31efe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,18 +8,6 @@ ARG TZ='UTC' ENV DEFAULT_TZ=${TZ} -RUN apk add --no-cache \ - libxml2-dev \ - libxslt-dev \ - python3-dev \ - make \ - gcc \ - libffi-dev \ - build-base \ - openssl-dev \ - cargo \ - tzdata - # Fix the warning where no timezone is specified RUN cp /usr/share/zoneinfo/${DEFAULT_TZ} /etc/localtime