forked from fjudith/docker-draw.io
-
-
Notifications
You must be signed in to change notification settings - Fork 441
Bad Dockerfile #202
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
The Dockerfile for export-server (image-export/Dockerfile) is not good:
FROM node:slim
LABEL maintainer="JGraph Ltd"
RUN apt-get update -y && \
apt-get install -y --no-install-recommends \
git curl software-properties-common chromium libatk-bridge2.0-0 libgtk-3-0 && \
apt-add-repository contrib && \
apt-get update -y && \
apt-get install -y --no-install-recommends \
ttf-mscorefonts-installer && \
mkdir /usr/local/drawio && \
cd /usr/local/drawio && \
git clone https://github.com/jgraph/draw-image-export2.git && \
cd draw-image-export2 && \
npm install && \
apt-get remove -y --purge chromium git
WORKDIR /usr/local/drawio/draw-image-export2
EXPOSE 8000
CMD ["npm", "start"]Review:
- Label
maintaineris outdated.
Useorg.opencontainers.image.***labels. - At next, setting the following set of OCI labels will allow for container inspection tools:
... --label "org.opencontainers.image.title=..." \ --label "org.opencontainers.image.description=..." \ --label "org.opencontainers.image.authors=Firstname Lastname <email@address.com>" \ --label "org.opencontainers.image.vendor=..." \ --label "org.opencontainers.image.version=1.0" \ --label "org.opencontainers.image.revision=${CI_COMMIT_SHA}" \ --label "org.opencontainers.image.created=$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \ --label "org.opencontainers.image.url=${CI_PROJECT_URL}" \ --label "org.opencontainers.image.source=$(printf ${CI_REPOSITORY_URL} | sed 's|//.*@|//|')" \ --label "org.opencontainers.image.documentation=${CI_PROJECT_URL}" \ --label "org.opencontainers.image.license=MIT" \ ... apt-get updateandapt-get installexist two times.
Reorder theapt-getcommands to void duplications and reduce build time.- Why is
chromiuminstalled?
It's later uninstalled and obviously no dependency. - Don't clone source files in a Dockerfile.
Sources are cloned outside of the Docker build process and handed over into the Docker build process via
RUN --mount=type=bind,target=/context:RUN --mount=type=bind,target=/context \ mkdir -p /tools \ && cp /context/ToolBox.sh /tools/ - Only copy necessary files into the Docker image. For sure, the Git repository contains unnecessary files.
Specify a.dockerignorefile to reduce the visible files in a Docker build context. - At best specify a list of packages to install in an external file, instead of listing individual dependencies in the Dockerfile.
RUN --mount=type=bind,target=/context \ apt-get update \ && xargs --no-run-if-empty --exit --arg-file=/context/Install.packages apt-get install -y --no-install-recommends \ && rm -rf /var/lib/apt/lists/* \ && apt-get clean - When removing
chromiumandgit, the apt caches are not cleaned !
Runrm -rf /var/lib/apt/lists/*andapt-get clean.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request