Skip to content

Commit

Permalink
dev server setup and pdf export (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
JannikStreek authored Jan 4, 2024
1 parent d3f3dcf commit eada79d
Show file tree
Hide file tree
Showing 11 changed files with 295 additions and 16 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
name: Create and publish a Docker image

on:
push:
branches:
- kits
release:
types: [published]

Expand Down Expand Up @@ -56,4 +53,5 @@ jobs:
ETHERPAD_PLUGINS=kitsteam/ep_comments_page kitsteam/ep_push2delete ep_image_upload ep_embedded_hyperlinks2 ep_headings2 ep_align ep_font_color ep_delete_empty_pads ep_delete_after_delay ep_helmet ep_font_size ep_disable_imports
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
target: production
27 changes: 19 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# Author: muxator

FROM node:lts-alpine
FROM node:lts-alpine as build
LABEL maintainer="Etherpad team, https://github.com/ether/etherpad-lite"

ARG TIMEZONE=
Expand Down Expand Up @@ -44,11 +44,6 @@ ARG INSTALL_ABIWORD=
# INSTALL_LIBREOFFICE=true
ARG INSTALL_SOFFICE=

# By default, Etherpad container is built and run in "production" mode. This is
# leaner (development dependencies are not installed) and runs faster (among
# other things, assets are minified & compressed).
ENV NODE_ENV=production
ENV ETHERPAD_PRODUCTION=true
# Install dependencies required for modifying access.
RUN apk add shadow bash
# Follow the principle of least privilege: run as unprivileged user.
Expand All @@ -63,8 +58,6 @@ ARG EP_UID=5001
ARG EP_GID=0
ARG EP_SHELL=

ENV NODE_ENV=production

RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \
useradd --system ${EP_UID:+--uid "${EP_UID}" --non-unique} --gid etherpad \
${EP_HOME:+--home-dir "${EP_HOME}"} --create-home \
Expand All @@ -89,6 +82,24 @@ USER etherpad

WORKDIR "${EP_DIR}"

FROM build as development

COPY --chown=etherpad:etherpad ./src/package.json ./src/package-lock.json ./src/
COPY --chown=etherpad:etherpad ./src/bin ./src/bin
COPY --chown=etherpad:etherpad ${SETTINGS} "${EP_DIR}"/settings.json

RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \
npm install --no-save --legacy-peer-deps ${ETHERPAD_PLUGINS}; } && \
src/bin/installDeps.sh

FROM build as production

# By default, Etherpad container is built and run in "production" mode. This is
# leaner (development dependencies are not installed) and runs faster (among
# other things, assets are minified & compressed).
ENV NODE_ENV=production
ENV ETHERPAD_PRODUCTION=true

COPY --chown=etherpad:etherpad ./ ./

# Plugins must be installed before installing Etherpad's dependencies, otherwise
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ We're looking for maintainers and have some funding available. Please contact J
[![Code Quality](https://github.com/ether/etherpad-lite/actions/workflows/codeql-analysis.yml/badge.svg?color=%2344b492)](https://github.com/ether/etherpad-lite/actions/workflows/codeql-analysis.yml)
[![package.lock](https://github.com/ether/etherpad-lite/actions/workflows/lint-package-lock.yml/badge.svg?color=%2344b492)](https://github.com/ether/etherpad-lite/actions/workflows/lint-package-lock.yml)

### Development

```
docker-compose up -d --build --force-recreate
./bin/run.sh
```


### Testing

[![Backend tests](https://github.com/ether/etherpad-lite/actions/workflows/backend-tests.yml/badge.svg?color=%2344b492)](https://github.com/ether/etherpad-lite/actions/workflows/backend-tests.yml)
Expand Down
1 change: 1 addition & 0 deletions docker-compose-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ services:
ep_helmet
ep_font_size
ep_disable_imports
target: production
depends_on:
- postgres_prod
environment:
Expand Down
72 changes: 72 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
version: "3.8"

# Add this file to extend the docker-compose setup, e.g.:
# docker-compose build --no-cache
# docker-compose up -d --build --force-recreate

services:
app:
build:
context: .
args:
ETHERPAD_PLUGINS: >-
kitsteam/ep_comments_page
ep_image_upload
kitsteam/ep_push2delete
ep_embedded_hyperlinks2
ep_headings2
ep_align
ep_font_color
ep_delete_empty_pads
ep_delete_after_delay
ep_helmet
ep_font_size
ep_disable_imports
target: development
tty: true
stdin_open: true
volumes:
- .:/opt/etherpad-lite
- node_modules:/opt/etherpad-lite/src/node_modules
depends_on:
- postgres
environment:
NODE_ENV: development
ETHERPAD_PRODUCTION: false
DB_CHARSET: ${DOCKER_COMPOSE_APP_DEV_ENV_DB_CHARSET:-utf8mb4}
DB_HOST: postgres
DB_NAME: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_DATABASE:?}
DB_PASS: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_PASSWORD:?}
DB_PORT: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_PORT:-5432}
DB_TYPE: "postgres"
DB_USER: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_USER:?}
# For now, the env var DEFAULT_PAD_TEXT cannot be unset or empty; it seems to be mandatory in the latest version of etherpad
DEFAULT_PAD_TEXT: ${DOCKER_COMPOSE_APP_DEV_ENV_DEFAULT_PAD_TEXT:- }
DISABLE_IP_LOGGING: ${DOCKER_COMPOSE_APP_DEV_ENV_DISABLE_IP_LOGGING:-true}
SOFFICE: ${DOCKER_COMPOSE_APP_DEV_ENV_SOFFICE:-null}
TRUST_PROXY: ${DOCKER_COMPOSE_APP_DEV_ENV_TRUST_PROXY:-true}
restart: always
ports:
- "${DOCKER_COMPOSE_APP_DEV_PORT_PUBLISHED:-9001}:${DOCKER_COMPOSE_APP_DEV_PORT_TARGET:-9001}"

postgres:
image: postgres:12-alpine
# Pass config parameters to the mysql server.
# Find more information below when you need to generate the ssl-relevant file your self
environment:
POSTGRES_DB: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_DATABASE:?}
POSTGRES_PASSWORD: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_PASSWORD:?}
POSTGRES_PORT: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_PORT:-5432}
POSTGRES_USER: ${DOCKER_COMPOSE_POSTGRES_DEV_ENV_POSTGRES_USER:?}
PGDATA: /var/lib/postgresql/data/pgdata
restart: always
# Exposing the port is not needed unless you want to access this database instance from the host.
# Be careful when other postgres docker container are running on the same port
# ports:
# - "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data/pgdata

volumes:
postgres_data:
node_modules:
2 changes: 2 additions & 0 deletions src/node/utils/ExportHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ exports.getPadHTMLDocument = async (padId, revNum, readOnlyId) => {
stylesForExportCSS += css;
});

stylesForExportCSS += '@page { size: letter; }';

let html = await getPadHTML(pad, revNum);

for (const hookHtml of await hooks.aCallAll('exportHTMLAdditionalContent', {padId})) {
Expand Down
3 changes: 3 additions & 0 deletions src/node/utils/Minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const LIBRARY_WHITELIST = [
'tinycon',
'underscore',
'unorm',
'jspdf',
'dompurify',
'html2canvas'
];

// What follows is a terrible hack to avoid loop-back within the server.
Expand Down
Loading

0 comments on commit eada79d

Please sign in to comment.