diff --git a/tools/ci/README.md b/tools/ci/README.md index b65ee8c2714..08dc4068ea4 100644 --- a/tools/ci/README.md +++ b/tools/ci/README.md @@ -24,3 +24,42 @@ with the chosen name: ```bash docker run -t ``` + +# Ydoc NodeJS Docker + +## Building + +To build a NodeJS-based Ydoc, you need to first ensure that you have the +distributable sources: + +```bash +pnpm -r compile +``` + +the resulting artifacts are located in `app/ydoc-server-nodejs/dist` directory. +Having the right NodeJS sources in place, one can now build the docker image: + +```bash +ocker build -t ydoc-server-nodejs:latest -f tools/ci/docker/ydoc-server/Dockerfile --build-context docker-tools=tools/ci/docker/ydoc-server app/ydoc-server-nodejs +``` + +## Running + +One should always start Ydoc with the right configuration: + +- PORT - the port number under which Ydoc will be available +- HOSTNAME - the hostname under which Ydoc will be available +- LANGUAGE_SERVER_URL - the full url (with port number) of the language server + to connect to + +```bash +docker run -it -e PORT=1234 -e HOSTNAME='0.0.0.0' -e LANGUAGE_SERVER_URL=ws://localhost:59876 ydoc-server-nodejs:latest +``` + +When correctly setup the network layer one can also hit Ydoc's healthcheck +endpoint: + +```bash +> curl http://${HOSTNAME}:${PORT}/_health +OK +``` diff --git a/tools/ci/docker/ydoc-server/Dockerfile b/tools/ci/docker/ydoc-server/Dockerfile new file mode 100644 index 00000000000..40327d4de13 --- /dev/null +++ b/tools/ci/docker/ydoc-server/Dockerfile @@ -0,0 +1,39 @@ +FROM node:20.16-bookworm-slim + +USER root + +ARG LOG_LEVEL=info +ARG YDOC_SERVER_PORT=5976 +ARG YDOC_SERVER_HOSTNAME=localhost +ARG YDOC_SERVER_LANGUAGE_SERVER_URL +ARG YDOC_SERVER_DEBUG=false + +RUN useradd -u 2000 -c 'Enso Developer' -U -m ensodev + +RUN mkdir /opt/ydoc-server-nodejs +RUN mkdir /opt/ydoc-server-nodejs/logs +RUN mkdir /opt/ydoc-server-nodejs/bin + +ADD dist/* /opt/ydoc-server-nodejs + +COPY --from=docker-tools ydoc-server-entrypoint.sh /opt/ydoc-server-nodejs/bin/ + +RUN chown -hR ensodev:ensodev /opt/ydoc-server-nodejs +RUN chmod -R u=rX,g=rX /opt/ydoc-server-nodejs +RUN chmod a+rw /opt/ydoc-server-nodejs/logs +RUN chmod a+rw /opt/ydoc-server-nodejs/logs +RUN chmod a+x /opt/ydoc-server-nodejs/bin/* + +USER ensodev:ensodev + +WORKDIR /opt/ydoc-server-nodejs + +ENTRYPOINT [ "/opt/ydoc-server-nodejs/bin/ydoc-server-entrypoint.sh" ] + +ENV LOG_LEVEL=${LOG_LEVEL} +ENV PORT=${YDOC_SERVER_PORT} +ENV HOSTNAME=${YDOC_SERVER_HOSTNAME} +ENV LANGUAGE_SERVER_URL=${YDOC_SERVER_LANGUAGE_SERVER_URL} +ENV ENSO_YDOC_LS_DEBUG=${YDOC_SERVER_DEBUG} + +EXPOSE ${PORT} diff --git a/tools/ci/docker/ydoc-server/ydoc-server-entrypoint.sh b/tools/ci/docker/ydoc-server/ydoc-server-entrypoint.sh new file mode 100755 index 00000000000..1ad3a44dd4c --- /dev/null +++ b/tools/ci/docker/ydoc-server/ydoc-server-entrypoint.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -e + +node main.mjs "$@"