optimize Dockerfile

- use stretch-slim instead of stretch
- use multistage builds
pull/1/head
Thomas Berger 6 years ago committed by Thomas Berger
parent 1460003483
commit ba6167eb5d

@ -1,9 +1,26 @@
# 6-stretch is the ONLY node 6 release supported by arm32v7, arm64v8 and x86-64 docker hub labels # We use multi stage builds
FROM node:6-stretch FROM node:6-stretch-slim AS build
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -yq git jq python
RUN npm install -g bower
# install tini in this stage to avoid the need of jq and python
# in the final image
ADD docker-install-tini.sh /usr/local/bin/docker-install-tini.sh
RUN /usr/local/bin/docker-install-tini.sh
COPY . /cryptpad
WORKDIR /cryptpad
RUN npm install --production \
&& npm install -g bower \
&& bower install --allow-root
FROM node:6-stretch-slim
# You want USE_SSL=true if not putting cryptpad behind a proxy # You want USE_SSL=true if not putting cryptpad behind a proxy
ENV USE_SSL=false ENV USE_SSL=false
ENV STORAGE=\'./storage/file\' ENV STORAGE="'./storage/file'"
ENV LOG_TO_STDOUT=true ENV LOG_TO_STDOUT=true
# Persistent storage needs # Persistent storage needs
@ -16,36 +33,14 @@ VOLUME /cryptpad/block
VOLUME /cryptpad/blob VOLUME /cryptpad/blob
VOLUME /cryptpad/blobstage VOLUME /cryptpad/blobstage
# Required packages # Copy cryptpad and tini from the build container
# jq is a build only dependency, removed in cleanup stage COPY --from=build /sbin/tini /sbin/tini
RUN apt-get update \ COPY --from=build /cryptpad /cryptpad
&& apt-get install -y --no-install-recommends \
git jq python
# Install tini for faux init
# sleep 1 is to ensure overlay2 can catch up with the copy prior to running chmod
COPY ./docker-install-tini.sh /
RUN chmod a+x /docker-install-tini.sh \
&& sleep 1 \
&& /docker-install-tini.sh \
&& rm /docker-install-tini.sh
# Cleanup apt
RUN apt-get remove -y --purge jq python \
&& apt-get auto-remove -y \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install cryptpad
COPY . /cryptpad
WORKDIR /cryptpad WORKDIR /cryptpad
RUN npm install --production \
&& npm install -g bower \
&& bower install --allow-root
# Unsafe / Safe ports # Unsafe / Safe ports
EXPOSE 3000 3001 EXPOSE 3000 3001
# Run cryptpad on startup # Run cryptpad on startup
CMD ["/sbin/tini", "--", "/cryptpad/container-start.sh"] CMD ["/sbin/tini", "--", "/cryptpad/container-start.sh"]
Loading…
Cancel
Save