From ed3ee8e5d8249a3556b41054da46c6f0168c705a Mon Sep 17 00:00:00 2001 From: Thomas Boerger Date: Wed, 5 Jun 2024 10:50:42 +0200 Subject: [PATCH] fix: reduce container size by removing __pycache__ folders --- deployment/docker/runner/Dockerfile | 6 ++++-- deployment/docker/server/Dockerfile | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/deployment/docker/runner/Dockerfile b/deployment/docker/runner/Dockerfile index bcd03d7f..8023f9aa 100644 --- a/deployment/docker/runner/Dockerfile +++ b/deployment/docker/runner/Dockerfile @@ -36,7 +36,8 @@ RUN apk add --no-cache -U \ chown -R semaphore:0 /tmp/semaphore && \ chown -R semaphore:0 /etc/semaphore && \ chown -R semaphore:0 /var/lib/semaphore && \ - chown -R semaphore:0 /opt/semaphore + chown -R semaphore:0 /opt/semaphore && \ + find /usr/lib/python* -iname __pycache__ | xargs rm -rf COPY --chown=1001:0 ./deployment/docker/runner/ansible.cfg /tmp/semaphore/ansible.cfg COPY --from=builder /go/src/semaphore/deployment/docker/runner/runner-wrapper /usr/local/bin/ @@ -56,7 +57,8 @@ ENV ANSIBLE_VERSION 9.4.0 RUN mkdir /opt/semaphore/venv && \ python3 -m venv /opt/semaphore/venv --system-site-packages && \ source /opt/semaphore/venv/bin/activate && \ - pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests + pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests && \ + find /opt/semaphore/venv -iname __pycache__ | xargs rm -rf # Preventing ansible zombie processes. Tini kills zombies. ENTRYPOINT ["/sbin/tini", "--"] diff --git a/deployment/docker/server/Dockerfile b/deployment/docker/server/Dockerfile index 9bdae616..e7a2bac3 100644 --- a/deployment/docker/server/Dockerfile +++ b/deployment/docker/server/Dockerfile @@ -36,7 +36,8 @@ bash curl git gnupg mysql-client openssh-client-default python3 python3-dev py3- chown -R semaphore:0 /tmp/semaphore && \ chown -R semaphore:0 /etc/semaphore && \ chown -R semaphore:0 /var/lib/semaphore && \ - chown -R semaphore:0 /opt/semaphore + chown -R semaphore:0 /opt/semaphore && \ + find /usr/lib/python* -iname __pycache__ | xargs rm -rf COPY --chown=1001:0 ./deployment/docker/server/ansible.cfg /tmp/semaphore/ansible.cfg COPY --from=builder /go/src/semaphore/deployment/docker/server/server-wrapper /usr/local/bin/ @@ -56,7 +57,8 @@ ENV ANSIBLE_VERSION 9.4.0 RUN mkdir /opt/semaphore/venv && \ python3 -m venv /opt/semaphore/venv --system-site-packages && \ source /opt/semaphore/venv/bin/activate && \ - pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests + pip3 install --upgrade pip ansible==${ANSIBLE_VERSION} boto3 botocore requests && \ + find /opt/semaphore/venv -iname __pycache__ | xargs rm -rf # Preventing ansible zombie processes. Tini kills zombies. ENTRYPOINT ["/sbin/tini", "--"]