2020-10-17 20:47:03 +00:00
|
|
|
# Multistage build to reduce image size and increase security
|
2022-04-20 14:30:18 +00:00
|
|
|
FROM node:16-alpine AS build
|
2020-10-17 20:47:03 +00:00
|
|
|
|
|
|
|
# Install requirements to clone repository and install deps
|
|
|
|
RUN apk add --no-cache git
|
|
|
|
RUN npm install -g bower
|
|
|
|
|
|
|
|
# Create folder for cryptpad
|
|
|
|
RUN mkdir /cryptpad
|
|
|
|
WORKDIR /cryptpad
|
|
|
|
|
|
|
|
# Get cryptpad from repository submodule
|
|
|
|
COPY cryptpad /cryptpad
|
|
|
|
|
|
|
|
RUN sed -i "s@//httpAddress: '::'@httpAddress: '0.0.0.0'@" /cryptpad/config/config.example.js
|
2021-06-22 10:58:00 +00:00
|
|
|
RUN sed -i "s@installMethod: 'unspecified'@installMethod: 'docker-alpine'@" /cryptpad/config/config.example.js
|
2020-10-17 20:47:03 +00:00
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
RUN npm install --production \
|
|
|
|
&& npm install -g bower \
|
|
|
|
&& bower install --allow-root
|
|
|
|
|
|
|
|
# Create actual cryptpad image
|
2022-04-20 14:30:18 +00:00
|
|
|
FROM node:16-alpine
|
2020-10-17 20:47:03 +00:00
|
|
|
|
|
|
|
# Create user and group for cryptpad so it does not run as root
|
|
|
|
RUN addgroup -g 4001 -S cryptpad \
|
|
|
|
&& adduser -u 4001 -S -D -g 4001 -H -h /cryptpad cryptpad
|
|
|
|
|
|
|
|
# Copy cryptpad with installed modules
|
|
|
|
COPY --from=build --chown=cryptpad /cryptpad /cryptpad
|
|
|
|
USER cryptpad
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# Ports
|
|
|
|
EXPOSE 3000 3001
|
|
|
|
|
|
|
|
# Run cryptpad on startup
|
2021-05-04 15:13:38 +00:00
|
|
|
CMD ["npm", "start"]
|