Skip to content

Commit

Permalink
Make Docker images smaller
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielCosme committed Mar 18, 2024
1 parent a72b9a8 commit 6bcc277
Showing 1 changed file with 112 additions and 31 deletions.
143 changes: 112 additions & 31 deletions hack/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,35 @@ ARG USER_ID=1000
ARG GROUP_ID=1000
ARG PYENV_DIR=/pyenv

RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
coreutils \
clamav \
libldap2-dev \
libsasl2-dev \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN set -ex \
&& groupadd --gid ${GROUP_ID} --system archivematica \
&& useradd --uid ${USER_ID} --gid ${GROUP_ID} --home-dir /var/archivematica --system archivematica \
&& mkdir -p /var/archivematica/sharedDirectory \
&& chown -R archivematica:archivematica /var/archivematica

# Download ClamAV virus signatures
RUN freshclam --quiet

USER archivematica

COPY --chown=${USER_ID}:${GROUP_ID} --from=pyenv-builder --link ${PYENV_DIR} ${PYENV_DIR}
COPY --chown=${USER_ID}:${GROUP_ID} --link . /src

# -----------------------------------------------------------------------------

FROM base AS archivematica-mcp-client

USER root

RUN set -ex \
&& curl --retry 3 -fsSL https://packages.archivematica.org/1.16.x/key.asc | gpg --dearmor -o /etc/apt/keyrings/archivematica-1.16.x.gpg \
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/archivematica-1.16.x.gpg] http://packages.archivematica.org/1.16.x/ubuntu-externals jammy main" > /etc/apt/sources.list.d/archivematica-external.list \
Expand All @@ -159,32 +188,20 @@ RUN set -ex \
&& apt-get install -y --no-install-recommends \
atool \
bulk-extractor \
clamav \
coreutils \
ffmpeg \
fits \
g++ \
gcc \
gearman \
gettext \
ghostscript \
hashdeep \
imagemagick \
inkscape \
jhove \
libffi-dev \
libimage-exiftool-perl \
libldap2-dev \
libmysqlclient-dev \
libsasl2-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
logapp \
md5deep \
nailgun \
mediaconch \
mediainfo \
nailgun \
nfs-common \
openjdk-8-jre-headless \
p7zip-full \
Expand All @@ -195,29 +212,12 @@ RUN set -ex \
sleuthkit \
tesseract-ocr \
tree \
unar \
unrar-free \
uuid \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN set -ex \
&& groupadd --gid ${GROUP_ID} --system archivematica \
&& useradd --uid ${USER_ID} --gid ${GROUP_ID} --home-dir /var/archivematica --system archivematica \
&& mkdir -p /var/archivematica/sharedDirectory \
&& chown -R archivematica:archivematica /var/archivematica

# Download ClamAV virus signatures
RUN freshclam --quiet

USER archivematica

COPY --chown=${USER_ID}:${GROUP_ID} --from=pyenv-builder --link ${PYENV_DIR} ${PYENV_DIR}
COPY --chown=${USER_ID}:${GROUP_ID} --link . /src

# -----------------------------------------------------------------------------

FROM base AS archivematica-mcp-client

ENV DJANGO_SETTINGS_MODULE settings.common
ENV PYTHONPATH /src/src/MCPClient/lib/:/src/src/MCPClient/lib/clientScripts:/src/src/archivematicaCommon/lib/:/src/src/dashboard/src/
ENV ARCHIVEMATICA_MCPCLIENT_ARCHIVEMATICACLIENTMODULES /src/src/MCPClient/lib/archivematicaClientModules
Expand Down Expand Up @@ -250,6 +250,19 @@ ARG PYTHON_VERSION=3.9

USER root

RUN set -ex \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
gcc \
g++ \
gettext \
libffi-dev \
libxml2-dev \
libxslt1-dev \
unar \
libssl-dev \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN set -ex \
&& internalDirs=' \
/src/src/dashboard/frontend \
Expand Down Expand Up @@ -283,7 +296,75 @@ ENTRYPOINT ["pyenv", "exec", "python3", "-m", "gunicorn", "--config=/src/src/das

# -----------------------------------------------------------------------------

FROM base AS archivematica-tests
FROM base-builder as archivematica-tests

ARG USER_ID=1000
ARG GROUP_ID=1000
ARG PYENV_DIR=/pyenv

RUN set -ex \
&& curl --retry 3 -fsSL https://packages.archivematica.org/1.16.x/key.asc | gpg --dearmor -o /etc/apt/keyrings/archivematica-1.16.x.gpg \
&& echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/archivematica-1.16.x.gpg] http://packages.archivematica.org/1.16.x/ubuntu-externals jammy main" > /etc/apt/sources.list.d/archivematica-external.list \
&& curl --retry 3 -so /tmp/repo-mediaarea_1.0-21_all.deb -L https://mediaarea.net/repo/deb/repo-mediaarea_1.0-21_all.deb \
&& dpkg -i /tmp/repo-mediaarea_1.0-21_all.deb \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
atool \
bulk-extractor \
clamav \
coreutils \
ffmpeg \
fits \
g++ \
gcc \
gearman \
gettext \
ghostscript \
hashdeep \
imagemagick \
inkscape \
jhove \
libffi-dev \
libimage-exiftool-perl \
libldap2-dev \
libmysqlclient-dev \
libsasl2-dev \
libssl-dev \
libxml2-dev \
libxslt1-dev \
logapp \
md5deep \
mediaconch \
mediainfo \
nailgun \
nfs-common \
openjdk-8-jre-headless \
p7zip-full \
pbzip2 \
pst-utils \
rsync \
siegfried \
sleuthkit \
tesseract-ocr \
tree \
unar \
unrar-free \
uuid \
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/*

RUN set -ex \
&& groupadd --gid ${GROUP_ID} --system archivematica \
&& useradd --uid ${USER_ID} --gid ${GROUP_ID} --home-dir /var/archivematica --system archivematica \
&& mkdir -p /var/archivematica/sharedDirectory \
&& chown -R archivematica:archivematica /var/archivematica

# Download ClamAV virus signatures
RUN freshclam --quiet

USER archivematica

COPY --chown=${USER_ID}:${GROUP_ID} --from=pyenv-builder --link ${PYENV_DIR} ${PYENV_DIR}
COPY --chown=${USER_ID}:${GROUP_ID} --link . /src

# -----------------------------------------------------------------------------

Expand Down

0 comments on commit 6bcc277

Please sign in to comment.