Merge branch '5.4-rc' of github.com:cryptpad/cryptpad into 5.4-rc

This commit is contained in:
yflory 2023-07-17 17:26:37 +02:00
commit ae40aa99cf
8 changed files with 257 additions and 2 deletions

9
.dockerignore Normal file
View File

@ -0,0 +1,9 @@
.dockerignore
.git
.gitignore
.gitmodules
.github
docker-compose.yml
traefik2.yml
Dockerfile*
*.png

69
.github/workflows/publish-release.yml vendored Normal file
View File

@ -0,0 +1,69 @@
# Needs secrets to be set for Docker Hub:
# DH_REGISTRY_USER
# DH_REGISTRY_PASSWORD
on:
push:
tags: [ '*' ]
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
IMAGE_NAME: ${{ github.repository_owner }}/cryptpad
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@1e95c1de343b5b0c23352d6417ee3e48d5bcd422
with:
cosign-release: 'v1.13.1'
# Use QEmu for multi architecture build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against Docker registry
# https://github.com/docker/login-action
- name: Log into registry
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
username: ${{ secrets.DH_REGISTRY_USER }}
password: ${{ secrets.DH_REGISTRY_PASSWORD }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

66
.github/workflows/publish.yml vendored Normal file
View File

@ -0,0 +1,66 @@
on:
push:
branches: [ main ]
tags: [ '*' ]
pull_request:
branches: [ main ]
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/cryptpad
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
# Use QEmu for multi architecture build
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

1
.gitignore vendored
View File

@ -23,4 +23,3 @@ block/
logs/
privileged.conf
config/config.js
*.sh

51
Dockerfile Normal file
View File

@ -0,0 +1,51 @@
# Multistage build to reduce image size and increase security
FROM node:lts-slim AS build
# Create folder for CryptPad
RUN mkdir /cryptpad
WORKDIR /cryptpad
# Copy CryptPad source code to the container
COPY . /cryptpad
RUN sed -i "s@//httpAddress: '::'@httpAddress: '0.0.0.0'@" /cryptpad/config/config.example.js
RUN sed -i "s@installMethod: 'unspecified'@installMethod: 'docker'@" /cryptpad/config/config.example.js
# Install dependencies
RUN npm install --production \
&& npm run install:components
# Create actual CryptPad image
FROM node:lts-slim
# Create user and group for CryptPad so it does not run as root
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
# Copy docker-entrypoint.sh script
COPY --chown=cryptpad docker-entrypoint.sh /cryptpad/docker-entrypoint.sh
# 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
ENTRYPOINT ["/bin/bash", "/cryptpad/docker-entrypoint.sh"]
# Ports
EXPOSE 3000 3001
# Run cryptpad on startup
CMD ["npm", "start"]

28
docker-compose.yml Normal file
View File

@ -0,0 +1,28 @@
---
version: '3.8'
services:
cryptpad:
image: "cryptpad/cryptpad:version-5.4.0"
hostname: cryptpad
environment:
- CPAD_MAIN_DOMAIN=https://your-main-domain.com
- CPAD_SANDBOX_DOMAIN=https://your-sandbox-domain.com
- CPAD_CONF=/cryptpad/config/config.js
volumes:
- ./data/blob:/cryptpad/blob
- ./data/block:/cryptpad/block
- ./customize:/cryptpad/customize
- ./data/data:/cryptpad/data
- ./data/files:/cryptpad/datastore
ports:
- "3000:3000"
- "3001:3001"
ulimits:
nofile:
soft: 1000000
hard: 1000000

31
docker-entrypoint.sh Executable file
View File

@ -0,0 +1,31 @@
#/bin/bash
## Required vars
# CPAD_MAIN_DOMAIN
# CPAD_SANDBOX_DOMAIN
# CPAD_CONF
set -e
CPAD_HOME="/cryptpad"
if [ ! -f "$CPAD_CONF" ]; then
echo -e "\n\
#################################################################### \n\
Warning: No config file provided for cryptpad \n\
We will create a basic one for now but you should rerun this service \n\
by providing a file with your settings \n\
eg: docker run -v /path/to/config.js:/cryptpad/config/config.js \n\
#################################################################### \n"
cp "$CPAD_HOME"/config/config.example.js "$CPAD_CONF"
sed -i -e "s@\(httpUnsafeOrigin:\).*[^,]@\1 '$CPAD_MAIN_DOMAIN'@" \
-e "s@\(^ *\).*\(httpSafeOrigin:\).*[^,]@\1\2 '$CPAD_SANDBOX_DOMAIN'@" $CPAD_CONF
fi
cd $CPAD_HOME
npm run build
exec "$@"

View File

@ -22,7 +22,9 @@ The most recent version and all past release notes can be found [here](https://g
## Setup using Docker
See [CryptPad-Docker](https://github.com/cryptpad/cryptpad-docker) repository for details on how to get up-and-running with CryptPad in Docker. This repository is maintained by the community and not officially supported.
You can find `Dockerfile`, `docker-compose.yml` and `docker-entrypoint.sh` files at the root of this repository. We also publish every release on [Docker Hub](https://hub.docker.com/r/cryptpad/cryptpad) as AMD64 & ARM64 official images.
Previously, Docker images were community maintained, had their own repository and weren't official supported. We changed that with v5.4.0 during July 2023. Thanks to @promasu for all the work on the community images.
# Security