2023-10-20 22:35:26 +08:00
|
|
|
# SPDX-FileCopyrightText: 2023 XWiki CryptPad Team <contact@cryptpad.org> and contributors
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
2023-05-16 21:02:52 +08:00
|
|
|
# Multistage build to reduce image size and increase security
|
2023-06-23 20:31:37 +08:00
|
|
|
FROM node:lts-slim AS build
|
2023-05-16 21:02:52 +08:00
|
|
|
|
2023-07-07 17:21:35 +08:00
|
|
|
# Create folder for CryptPad
|
2023-05-16 21:02:52 +08:00
|
|
|
RUN mkdir /cryptpad
|
|
|
|
WORKDIR /cryptpad
|
|
|
|
|
2023-07-07 17:21:35 +08:00
|
|
|
# Copy CryptPad source code to the container
|
2023-05-16 21:02:52 +08:00
|
|
|
COPY . /cryptpad
|
|
|
|
|
2023-12-21 01:13:19 +08:00
|
|
|
RUN sed -i "s@//httpAddress: 'localhost'@httpAddress: '0.0.0.0'@" /cryptpad/config/config.example.js
|
2023-06-23 20:31:37 +08:00
|
|
|
RUN sed -i "s@installMethod: 'unspecified'@installMethod: 'docker'@" /cryptpad/config/config.example.js
|
2024-07-06 16:23:49 +08:00
|
|
|
|
2023-05-16 21:02:52 +08:00
|
|
|
# Install dependencies
|
|
|
|
RUN npm install --production \
|
2023-07-11 16:05:14 +08:00
|
|
|
&& npm run install:components
|
2023-05-16 21:02:52 +08:00
|
|
|
|
2023-07-07 17:21:35 +08:00
|
|
|
# Create actual CryptPad image
|
2023-06-23 20:31:37 +08:00
|
|
|
FROM node:lts-slim
|
2024-02-26 15:37:25 +08:00
|
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
2023-05-16 21:02:52 +08:00
|
|
|
|
2023-07-07 17:21:35 +08:00
|
|
|
# Create user and group for CryptPad so it does not run as root
|
2023-06-23 20:31:37 +08:00
|
|
|
RUN groupadd cryptpad -g 4001
|
|
|
|
RUN useradd cryptpad -u 4001 -g 4001 -d /cryptpad
|
2023-05-16 21:02:52 +08:00
|
|
|
|
2024-04-09 17:51:06 +08:00
|
|
|
# Install curl for healthcheck
|
|
|
|
# Install git, rdfind and unzip for install-onlyoffice.sh
|
2024-04-09 15:04:14 +08:00
|
|
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
2024-04-09 17:51:06 +08:00
|
|
|
curl ca-certificates git rdfind unzip && \
|
2023-12-22 22:28:54 +08:00
|
|
|
apt-get clean && \
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
2023-05-16 21:02:52 +08:00
|
|
|
# Copy cryptpad with installed modules
|
|
|
|
COPY --from=build --chown=cryptpad /cryptpad /cryptpad
|
|
|
|
USER cryptpad
|
|
|
|
|
2023-06-22 21:05:50 +08:00
|
|
|
# Copy docker-entrypoint.sh script
|
2023-06-23 20:31:37 +08:00
|
|
|
COPY --chown=cryptpad docker-entrypoint.sh /cryptpad/docker-entrypoint.sh
|
2023-06-22 21:05:50 +08:00
|
|
|
|
2023-05-16 21:02:52 +08:00
|
|
|
# Set workdir to cryptpad
|
|
|
|
WORKDIR /cryptpad
|
|
|
|
|
|
|
|
# Create directories
|
2023-06-22 22:06:16 +08:00
|
|
|
RUN mkdir blob block customize data datastore
|
2023-05-16 21:02:52 +08:00
|
|
|
|
|
|
|
# Volumes for data persistence
|
|
|
|
VOLUME /cryptpad/blob
|
|
|
|
VOLUME /cryptpad/block
|
|
|
|
VOLUME /cryptpad/customize
|
|
|
|
VOLUME /cryptpad/data
|
|
|
|
VOLUME /cryptpad/datastore
|
|
|
|
|
2023-06-23 20:31:37 +08:00
|
|
|
ENTRYPOINT ["/bin/bash", "/cryptpad/docker-entrypoint.sh"]
|
|
|
|
|
2023-10-13 23:46:52 +08:00
|
|
|
# Healthcheck
|
2024-04-09 17:51:06 +08:00
|
|
|
HEALTHCHECK --interval=1m CMD curl -f http://localhost:3000/ || exit 1
|
2023-10-13 23:46:52 +08:00
|
|
|
|
2023-05-16 21:02:52 +08:00
|
|
|
# Ports
|
2024-05-17 16:26:35 +08:00
|
|
|
EXPOSE 3000 3003
|
2023-05-16 21:02:52 +08:00
|
|
|
|
|
|
|
# Run cryptpad on startup
|
|
|
|
CMD ["npm", "start"]
|