mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-27 10:56:16 -04:00
add docker dev setup (#6155)
* fix docker setup * wording fix * remove production env * remove unneeded docker parts * fix image size * add readme * add dev readme * further refactoring * make version work * cleanup ignore * refactor commit * fix pnpm mount
This commit is contained in:
parent
5d24593dd8
commit
03c8518e66
6 changed files with 147 additions and 18 deletions
49
Dockerfile
49
Dockerfile
|
@ -4,7 +4,7 @@
|
|||
#
|
||||
# Author: muxator
|
||||
|
||||
FROM node:alpine AS builder
|
||||
FROM node:alpine as build
|
||||
LABEL maintainer="Etherpad team, https://github.com/ether/etherpad-lite"
|
||||
|
||||
ARG TIMEZONE=
|
||||
|
@ -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.
|
||||
|
@ -63,9 +58,6 @@ ARG EP_UID=5001
|
|||
ARG EP_GID=0
|
||||
ARG EP_SHELL=
|
||||
|
||||
ARG NODE_ENV
|
||||
ENV NODE_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 \
|
||||
|
@ -74,7 +66,6 @@ RUN groupadd --system ${EP_GID:+--gid "${EP_GID}" --non-unique} etherpad && \
|
|||
ARG EP_DIR=/opt/etherpad-lite
|
||||
RUN mkdir -p "${EP_DIR}" && chown etherpad:etherpad "${EP_DIR}"
|
||||
|
||||
USER root
|
||||
# the mkdir is needed for configuration of openjdk-11-jre-headless, see
|
||||
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=863199
|
||||
RUN \
|
||||
|
@ -92,7 +83,31 @@ USER etherpad
|
|||
|
||||
WORKDIR "${EP_DIR}"
|
||||
|
||||
COPY --chown=etherpad:etherpad ./ ./
|
||||
# etherpads version feature requires this. Only copy what is really needed
|
||||
COPY --chown=etherpad:etherpad ./.git/HEAD ./.git/HEAD
|
||||
COPY --chown=etherpad:etherpad ./.git/refs ./.git/refs
|
||||
COPY --chown=etherpad:etherpad ${SETTINGS} ./settings.json
|
||||
COPY --chown=etherpad:etherpad ./var ./var
|
||||
COPY --chown=etherpad:etherpad ./node_modules ./node_modules
|
||||
|
||||
FROM build as development
|
||||
|
||||
COPY --chown=etherpad:etherpad ./src/package.json .npmrc ./src/pnpm-lock.yaml ./src/
|
||||
COPY --chown=etherpad:etherpad ./src/bin ./src/bin
|
||||
|
||||
RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \
|
||||
pnpm 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 ./src ./src
|
||||
|
||||
# Plugins must be installed before installing Etherpad's dependencies, otherwise
|
||||
# npm will try to hoist common dependencies by removing them from
|
||||
|
@ -103,7 +118,7 @@ COPY --chown=etherpad:etherpad ./ ./
|
|||
# seems to confuse tools such as `npm outdated`, `npm update`, and some ESLint
|
||||
# rules.
|
||||
RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \
|
||||
npm install --no-save --legacy-peer-deps ${ETHERPAD_PLUGINS}; } && \
|
||||
pnpm install --no-save --legacy-peer-deps ${ETHERPAD_PLUGINS}; } && \
|
||||
src/bin/installDeps.sh && \
|
||||
rm -rf ~/.npm
|
||||
|
||||
|
@ -111,15 +126,13 @@ RUN { [ -z "${ETHERPAD_PLUGINS}" ] || \
|
|||
COPY --chown=etherpad:etherpad ${SETTINGS} "${EP_DIR}"/settings.json
|
||||
|
||||
# Fix group permissions
|
||||
#RUN chmod -R g=u .
|
||||
|
||||
USER root
|
||||
# Note: For some reason increases image size from 257 to 334.
|
||||
# RUN chmod -R g=u .
|
||||
|
||||
USER etherpad
|
||||
|
||||
WORKDIR /opt/etherpad-lite
|
||||
|
||||
HEALTHCHECK --interval=5s --timeout=3s \
|
||||
CMD curl --silent http://localhost:9001/health | grep -E "pass|ok|up" > /dev/null || exit 1
|
||||
CMD curl --silent http://localhost:9001/health | grep -E "pass|ok|up" > /dev/null || exit 1
|
||||
|
||||
EXPOSE 9001
|
||||
CMD ["npm", "run", "prod", "--prefix", "./src"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue