Skip to content

Commit

Permalink
Optimize build caching
Browse files Browse the repository at this point in the history
Before this commit, if docker-entrypoint or any file in mailman-web changed, the Docker build cache would not be used, so the install of dependencies would run again, uselessly
  • Loading branch information
am97 committed Oct 11, 2023
1 parent 820b843 commit 02b8ed2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 35 deletions.
6 changes: 3 additions & 3 deletions core/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
# Use 3.15 for Core since it has Python 3.9
FROM alpine:3.18

#Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

# Add requirements file.
COPY requirements.txt /tmp/

Expand All @@ -25,6 +22,9 @@ RUN --mount=type=cache,target=/root/.cache \
&& apk del build-deps \
&& adduser -S mailman

#Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

# Change the working directory.
WORKDIR /opt/mailman

Expand Down
7 changes: 3 additions & 4 deletions core/Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
# Use 3.15 for Core since it has Python 3.9
FROM alpine:3.18

#Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

# Set the commits that we are building.
ARG CORE_REF
ARG MM3_HK_REF


#Install all required packages, add user for executing mailman and set execution
#rights for startup script
RUN --mount=type=cache,target=/root/.cache \
Expand All @@ -26,6 +22,9 @@ RUN --mount=type=cache,target=/root/.cache \
&& apk del build-deps \
&& adduser -S mailman

#Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

# Change the working directory.
WORKDIR /opt/mailman

Expand Down
15 changes: 8 additions & 7 deletions postorius/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.18.4

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

# Install packages and dependencies for postorius and hyperkitty Add user for
# executing apps, change ownership for uwsgi+django files and set execution
# rights for management script
Expand All @@ -27,8 +22,14 @@ RUN --mount=type=cache,target=/root/.cache \
python-memcached \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& adduser -S -G mailman mailman

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py

WORKDIR /opt/mailman-web
Expand Down
15 changes: 8 additions & 7 deletions postorius/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.18.4

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

ARG POSTORIUS_REF
ARG DJ_MM3_REF
ARG CLIENT_REF
Expand Down Expand Up @@ -35,8 +30,14 @@ RUN --mount=type=cache,target=/root/.cache \
git+https://gitlab.com/mailman/django-mailman3 \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& adduser -S -G mailman mailman

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py

WORKDIR /opt/mailman-web
Expand Down
14 changes: 8 additions & 6 deletions web/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.18.4

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/
# Add requirements file.
COPY requirements.txt /tmp/

Expand Down Expand Up @@ -34,8 +30,14 @@ RUN --mount=type=cache,target=/root/.cache \
tzdata \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& adduser -S -G mailman mailman

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py

WORKDIR /opt/mailman-web
Expand Down
17 changes: 9 additions & 8 deletions web/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# syntax = docker/dockerfile:1.3
FROM alpine:3.18.4

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

ARG POSTORIUS_REF
ARG HYPERKITTY_REF
ARG DJ_MM3_REF
Expand Down Expand Up @@ -42,9 +37,15 @@ RUN --mount=type=cache,target=/root/.cache \
git+https://gitlab.com/mailman/django-mailman3 \
&& apk del .build-deps \
&& addgroup -S mailman \
&& adduser -S -G mailman mailman \
&& chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py
&& adduser -S -G mailman mailman

# Add needed files for uwsgi server + settings for django
COPY mailman-web /opt/mailman-web
# Add startup script to container
COPY docker-entrypoint.sh /usr/local/bin/

RUN chown -R mailman /opt/mailman-web/ \
&& chmod u+x /opt/mailman-web/manage.py

WORKDIR /opt/mailman-web

Expand Down

0 comments on commit 02b8ed2

Please sign in to comment.