add container and update mermaid
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -18,6 +18,7 @@ backups/
|
|||||||
|
|
||||||
# ignore config files
|
# ignore config files
|
||||||
config.json
|
config.json
|
||||||
|
!/resources/config.json
|
||||||
.sequelizerc
|
.sequelizerc
|
||||||
|
|
||||||
# ignore webpack build
|
# ignore webpack build
|
||||||
|
|||||||
85
Dockerfile
Normal file
85
Dockerfile
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
FROM docker.io/library/node:20.17.0-alpine@sha256:2d07db07a2df6830718ae2a47db6fedce6745f5bcd174c398f2acdda90a11c03 AS builder
|
||||||
|
|
||||||
|
# Build arguments to change source url, branch or tag
|
||||||
|
ARG CODIMD_REPOSITORY
|
||||||
|
ARG HEDGEDOC_REPOSITORY=https://gitea.finnvanreenen.nl/LailaTheElf/hedgedoc.git
|
||||||
|
ARG VERSION=master
|
||||||
|
#necessary on ARM because puppeteer doesn't provide a prebuilt binary
|
||||||
|
ENV PUPPETEER_SKIP_DOWNLOAD=true
|
||||||
|
ENV YARN_CACHE_FOLDER=/tmp/.yarn
|
||||||
|
|
||||||
|
RUN if [ -n "${CODIMD_REPOSITORY}" ]; then echo "CODIMD_REPOSITORY is deprecated. Please use HEDGEDOC_REPOSITORY instead" && exit 1; fi
|
||||||
|
|
||||||
|
# Clone the source and remove git repository but keep the HEAD file
|
||||||
|
RUN --mount=target=/var/cache/apk,type=cache,sharing=locked \
|
||||||
|
apk update && \
|
||||||
|
apk add git jq python3 build-base
|
||||||
|
# RUN git clone --depth 1 --branch "$VERSION" "$HEDGEDOC_REPOSITORY" /hedgedoc
|
||||||
|
COPY . /hedgedoc
|
||||||
|
# RUN git -C /hedgedoc log --pretty=format:'%ad %h %d' --abbrev-commit --date=short -1
|
||||||
|
# RUN git -C /hedgedoc rev-parse HEAD > /tmp/gitref
|
||||||
|
RUN rm -rf /hedgedoc/.git/*
|
||||||
|
# RUN mv /tmp/gitref /hedgedoc/.git/HEAD
|
||||||
|
# RUN jq ".repository.url = \"${HEDGEDOC_REPOSITORY}\"" /hedgedoc/package.json > /hedgedoc/package.new.json
|
||||||
|
# RUN mv /hedgedoc/package.new.json /hedgedoc/package.json
|
||||||
|
|
||||||
|
# Install app dependencies and build
|
||||||
|
WORKDIR /hedgedoc
|
||||||
|
RUN --mount=type=cache,sharing=locked,target=/tmp/.yarn yarn install --immutable
|
||||||
|
RUN yarn run build
|
||||||
|
|
||||||
|
FROM docker.io/library/node:20.17.0-alpine@sha256:2d07db07a2df6830718ae2a47db6fedce6745f5bcd174c398f2acdda90a11c03 AS modules-installer
|
||||||
|
WORKDIR /hedgedoc
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV YARN_CACHE_FOLDER=/tmp/.yarn
|
||||||
|
|
||||||
|
COPY --from=builder /hedgedoc /hedgedoc
|
||||||
|
|
||||||
|
RUN --mount=target=/var/cache/apk,type=cache,sharing=locked \
|
||||||
|
apk update && \
|
||||||
|
apk add git python3 build-base
|
||||||
|
|
||||||
|
RUN --mount=type=cache,sharing=locked,target=/tmp/.yarn yarn workspaces focus --production
|
||||||
|
|
||||||
|
FROM docker.io/library/node:20.17.0-alpine@sha256:2d07db07a2df6830718ae2a47db6fedce6745f5bcd174c398f2acdda90a11c03 AS app
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.title='HedgeDoc production image(alpine)'
|
||||||
|
LABEL org.opencontainers.image.url='https://hedgedoc.org'
|
||||||
|
LABEL org.opencontainers.image.source='https://gitea.finnvanreenen.nl/LailaTheElf/hedgedoc'
|
||||||
|
LABEL org.opencontainers.image.documentation='https://github.com/hedgedoc/container/blob/master/README.md'
|
||||||
|
LABEL org.opencontainers.image.licenses='AGPL-3.0'
|
||||||
|
|
||||||
|
WORKDIR /hedgedoc
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ARG UID=10000
|
||||||
|
ENV UPLOADS_MODE=0700
|
||||||
|
|
||||||
|
RUN apk add --no-cache --no-progress --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing/ gosu
|
||||||
|
|
||||||
|
# Create hedgedoc user
|
||||||
|
RUN adduser -u $UID -h /hedgedoc/ -D -S hedgedoc
|
||||||
|
|
||||||
|
COPY --chown=$UID --from=modules-installer /hedgedoc /hedgedoc
|
||||||
|
|
||||||
|
# Add configuraton files
|
||||||
|
COPY ["resources/config.json", "/files/"]
|
||||||
|
|
||||||
|
# Healthcheck
|
||||||
|
COPY --chown=$UID /resources/healthcheck.mjs /hedgedoc/healthcheck.mjs
|
||||||
|
HEALTHCHECK --interval=15s CMD node healthcheck.mjs
|
||||||
|
|
||||||
|
# For backwards compatibility
|
||||||
|
RUN ln -s /hedgedoc /codimd
|
||||||
|
|
||||||
|
# Symlink configuration files
|
||||||
|
RUN rm -f /hedgedoc/config.json
|
||||||
|
RUN ln -s /files/config.json /hedgedoc/config.json
|
||||||
|
|
||||||
|
EXPOSE 3000
|
||||||
|
|
||||||
|
COPY ["resources/docker-entrypoint.sh", "/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
||||||
|
|
||||||
|
CMD ["node", "app.js"]
|
||||||
14
package.json
14
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "HedgeDoc",
|
"name": "the_hedgedoc_elf",
|
||||||
"version": "1.10.1",
|
"version": "1.10.2",
|
||||||
"description": "The best platform to write and share markdown.",
|
"description": "The best platform to write and share markdown.",
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18"
|
"node": ">=18"
|
||||||
},
|
},
|
||||||
"bugs": "https://github.com/hedgedoc/hedgedoc/issues",
|
"bugs": "https://gitea.finnvanreenen.nl/LailaTheElf/hedgedoc/issues",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"Collaborative",
|
"Collaborative",
|
||||||
"Markdown",
|
"Markdown",
|
||||||
@@ -118,6 +118,10 @@
|
|||||||
],
|
],
|
||||||
"homepage": "https://hedgedoc.org",
|
"homepage": "https://hedgedoc.org",
|
||||||
"maintainers": [
|
"maintainers": [
|
||||||
|
{
|
||||||
|
"name": "LailaTheElf",
|
||||||
|
"email": "mail@lailatheelf.nl"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Claudius Coenen",
|
"name": "Claudius Coenen",
|
||||||
"url": "https://www.claudiuscoenen.de/"
|
"url": "https://www.claudiuscoenen.de/"
|
||||||
@@ -134,7 +138,7 @@
|
|||||||
],
|
],
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/hedgedoc/hedgedoc.git"
|
"url": "https://gitea.finnvanreenen.nl/LailaTheElf/hedgedoc.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/eslintrc": "3.2.0",
|
"@eslint/eslintrc": "3.2.0",
|
||||||
@@ -185,7 +189,7 @@
|
|||||||
"less-loader": "7.3.0",
|
"less-loader": "7.3.0",
|
||||||
"list.js": "2.3.1",
|
"list.js": "2.3.1",
|
||||||
"mathjax": "2.7.9",
|
"mathjax": "2.7.9",
|
||||||
"mermaid": "9.1.7",
|
"mermaid": "11.4.1",
|
||||||
"mini-css-extract-plugin": "1.6.2",
|
"mini-css-extract-plugin": "1.6.2",
|
||||||
"mocha": "11.1.0",
|
"mocha": "11.1.0",
|
||||||
"mock-require": "3.0.3",
|
"mock-require": "3.0.3",
|
||||||
|
|||||||
1
resources/config.json
Normal file
1
resources/config.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
58
resources/docker-entrypoint.sh
Executable file
58
resources/docker-entrypoint.sh
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Use gosu if the container started with root privileges
|
||||||
|
UID="$(id -u)"
|
||||||
|
[ "$UID" -eq 0 ] && GOSU="gosu hedgedoc" || GOSU=""
|
||||||
|
|
||||||
|
if [ "$HMD_IMAGE_UPLOAD_TYPE" != "" ] && [ "$CMD_IMAGE_UPLOAD_TYPE" = "" ]; then
|
||||||
|
CMD_IMAGE_UPLOAD_TYPE="$HMD_IMAGE_UPLOAD_TYPE"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Print warning if local data storage is used but no volume is mounted
|
||||||
|
[ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ] && { mountpoint -q ./public/uploads || {
|
||||||
|
echo "
|
||||||
|
#################################################################
|
||||||
|
### ###
|
||||||
|
### !!!WARNING!!! ###
|
||||||
|
### ###
|
||||||
|
### Using local uploads without persistence is ###
|
||||||
|
### dangerous. You'll loose your data on ###
|
||||||
|
### container removal. Check out: ###
|
||||||
|
### https://docs.docker.com/engine/tutorials/dockervolumes/ ###
|
||||||
|
### ###
|
||||||
|
### !!!WARNING!!! ###
|
||||||
|
### ###
|
||||||
|
#################################################################
|
||||||
|
";
|
||||||
|
} ; }
|
||||||
|
|
||||||
|
# Change owner and permission if filesystem backend is used and user has root permissions
|
||||||
|
if [ "$UID" -eq 0 ] && [ "$CMD_IMAGE_UPLOAD_TYPE" = "filesystem" ]; then
|
||||||
|
if [ "$UID" -eq 0 ]; then
|
||||||
|
echo "Updating uploads directory permissions ($UPLOADS_MODE)"
|
||||||
|
chown -R hedgedoc ./public/uploads
|
||||||
|
chmod $UPLOADS_MODE ./public/uploads
|
||||||
|
find ./public/uploads -type f -executable -exec chmod a-x {} \;
|
||||||
|
else
|
||||||
|
echo "
|
||||||
|
#################################################################
|
||||||
|
### ###
|
||||||
|
### !!!WARNING!!! ###
|
||||||
|
### ###
|
||||||
|
### Container was started without root permissions ###
|
||||||
|
### and filesystem storage is being used. ###
|
||||||
|
### In case of filesystem errors these need to be ###
|
||||||
|
### changed manually ###
|
||||||
|
### ###
|
||||||
|
### !!!WARNING!!! ###
|
||||||
|
### ###
|
||||||
|
#################################################################
|
||||||
|
";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sleep to make sure everything is fine...
|
||||||
|
sleep 3
|
||||||
|
|
||||||
|
# run
|
||||||
|
exec $GOSU "$@"
|
||||||
20
resources/healthcheck.mjs
Normal file
20
resources/healthcheck.mjs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
|
// Kill myself after 5 second timeout
|
||||||
|
setTimeout(() => {
|
||||||
|
process.exit(1)
|
||||||
|
}, 5000)
|
||||||
|
|
||||||
|
fetch(`http://localhost:${process.env.CMD_PORT || '3000' }/_health`, {headers: { "user-agent": "hedgedoc-container-healthcheck/1.1"}}).then((response) => {
|
||||||
|
if (!response.ok) {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
return response.json()
|
||||||
|
}).then((data) => {
|
||||||
|
if (!data.ready) {
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
process.exit(0)
|
||||||
|
}).catch(() => {
|
||||||
|
process.exit(1)
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user