cryptpad/Dockerfile

52 lines
1.3 KiB
Docker
Raw Normal View History

# Multistage build to reduce image size and increase security
2023-06-23 12:31:37 +00:00
FROM node:lts-slim AS build
2023-07-07 09:21:35 +00:00
# Create folder for CryptPad
RUN mkdir /cryptpad
WORKDIR /cryptpad
2023-07-07 09:21:35 +00:00
# Copy CryptPad source code to the container
COPY . /cryptpad
RUN sed -i "s@//httpAddress: '::'@httpAddress: '0.0.0.0'@" /cryptpad/config/config.example.js
2023-06-23 12:31:37 +00:00
RUN sed -i "s@installMethod: 'unspecified'@installMethod: 'docker'@" /cryptpad/config/config.example.js
# Install dependencies
RUN npm install --production \
2023-07-11 08:05:14 +00:00
&& npm run install:components
2023-07-07 09:21:35 +00:00
# Create actual CryptPad image
2023-06-23 12:31:37 +00:00
FROM node:lts-slim
2023-07-07 09:21:35 +00:00
# Create user and group for CryptPad so it does not run as root
2023-06-23 12:31:37 +00:00
RUN groupadd cryptpad -g 4001
RUN useradd cryptpad -u 4001 -g 4001 -d /cryptpad
# Copy cryptpad with installed modules
COPY --from=build --chown=cryptpad /cryptpad /cryptpad
USER cryptpad
2023-06-22 13:05:50 +00:00
# Copy docker-entrypoint.sh script
2023-06-23 12:31:37 +00:00
COPY --chown=cryptpad docker-entrypoint.sh /cryptpad/docker-entrypoint.sh
2023-06-22 13:05:50 +00:00
# Set workdir to cryptpad
WORKDIR /cryptpad
# Create directories
RUN mkdir blob block customize data datastore
# Volumes for data persistence
VOLUME /cryptpad/blob
VOLUME /cryptpad/block
VOLUME /cryptpad/customize
VOLUME /cryptpad/data
VOLUME /cryptpad/datastore
2023-06-23 12:31:37 +00:00
ENTRYPOINT ["/bin/bash", "/cryptpad/docker-entrypoint.sh"]
# Ports
2023-08-14 07:23:38 +00:00
EXPOSE 3000 3001 3003
# Run cryptpad on startup
CMD ["npm", "start"]