2022-02-03 12:11:06 +02:00
|
|
|
# =============================================================================
|
|
|
|
# Build stage
|
|
|
|
# =============================================================================
|
|
|
|
|
2022-11-04 13:32:13 +02:00
|
|
|
FROM node:18-bullseye AS builder
|
2021-08-23 10:51:26 +02:00
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
2022-02-20 13:14:42 +02:00
|
|
|
python tini \
|
2021-08-23 10:51:26 +02:00
|
|
|
&& rm -rf /var/lib/apt/lists/*
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2021-12-20 17:08:43 +02:00
|
|
|
# Enables Yarn
|
|
|
|
RUN corepack enable
|
|
|
|
|
2022-01-24 20:50:01 +02:00
|
|
|
WORKDIR /build
|
2021-01-18 12:13:26 +02:00
|
|
|
|
2022-01-24 20:50:01 +02:00
|
|
|
COPY .yarn/plugins ./.yarn/plugins
|
|
|
|
COPY .yarn/releases ./.yarn/releases
|
2023-07-01 13:52:30 +02:00
|
|
|
COPY .yarn/patches ./.yarn/patches
|
2022-01-24 20:50:01 +02:00
|
|
|
COPY package.json .
|
|
|
|
COPY .yarnrc.yml .
|
|
|
|
COPY yarn.lock .
|
|
|
|
COPY gulpfile.js .
|
|
|
|
COPY tsconfig.json .
|
|
|
|
COPY packages/turndown ./packages/turndown
|
|
|
|
COPY packages/turndown-plugin-gfm ./packages/turndown-plugin-gfm
|
|
|
|
COPY packages/fork-htmlparser2 ./packages/fork-htmlparser2
|
|
|
|
COPY packages/server/package*.json ./packages/server/
|
|
|
|
COPY packages/fork-sax ./packages/fork-sax
|
|
|
|
COPY packages/fork-uslug ./packages/fork-uslug
|
|
|
|
COPY packages/htmlpack ./packages/htmlpack
|
|
|
|
COPY packages/renderer ./packages/renderer
|
|
|
|
COPY packages/tools ./packages/tools
|
2023-03-20 15:43:25 +02:00
|
|
|
COPY packages/utils ./packages/utils
|
2022-01-24 20:50:01 +02:00
|
|
|
COPY packages/lib ./packages/lib
|
|
|
|
COPY packages/server ./packages/server
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2024-11-17 18:21:08 +02:00
|
|
|
# We don't want to build onenote-converter since it is not used by the server
|
|
|
|
RUN sed --in-place '/onenote-converter/d' ./packages/lib/package.json
|
|
|
|
|
2022-01-13 19:39:58 +02:00
|
|
|
# For some reason there's both a .yarn/cache and .yarn/berry/cache that are
|
|
|
|
# being generated, and both have the same content. Not clear why it does this
|
|
|
|
# but we can delete it anyway. We can delete the cache because we use
|
|
|
|
# `nodeLinker: node-modules`. If we ever implement Zero Install, we'll need to
|
|
|
|
# keep the cache.
|
|
|
|
#
|
|
|
|
# Note that `yarn install` ignores `NODE_ENV=production` and will install dev
|
|
|
|
# dependencies too, but this is fine because we need them to build the app.
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2022-01-13 19:39:58 +02:00
|
|
|
RUN BUILD_SEQUENCIAL=1 yarn install --inline-builds \
|
|
|
|
&& yarn cache clean \
|
|
|
|
&& rm -rf .yarn/berry
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2022-02-03 12:11:06 +02:00
|
|
|
# =============================================================================
|
|
|
|
# Final stage - we copy only the relevant files from the build stage and start
|
|
|
|
# from a smaller base image.
|
|
|
|
# =============================================================================
|
|
|
|
|
2022-11-05 18:51:09 +02:00
|
|
|
FROM node:18-bullseye-slim
|
2022-01-24 20:50:01 +02:00
|
|
|
|
|
|
|
ARG user=joplin
|
|
|
|
RUN useradd --create-home --shell /bin/bash $user
|
|
|
|
|
|
|
|
USER $user
|
|
|
|
|
|
|
|
COPY --chown=$user:$user --from=builder /build/packages /home/$user/packages
|
2022-02-20 13:14:42 +02:00
|
|
|
COPY --chown=$user:$user --from=builder /usr/bin/tini /usr/local/bin/tini
|
2022-01-24 20:50:01 +02:00
|
|
|
|
|
|
|
ENV NODE_ENV=production
|
|
|
|
ENV RUNNING_IN_DOCKER=1
|
|
|
|
EXPOSE ${APP_PORT}
|
|
|
|
|
|
|
|
# Use Tini to start Joplin Server:
|
|
|
|
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#handling-kernel-signals
|
|
|
|
WORKDIR /home/$user/packages/server
|
|
|
|
ENTRYPOINT ["tini", "--"]
|
2023-11-01 18:28:45 +02:00
|
|
|
CMD ["yarn", "start-prod"]
|
2021-07-08 15:04:03 +02:00
|
|
|
|
|
|
|
# Build-time metadata
|
|
|
|
# https://github.com/opencontainers/image-spec/blob/master/annotations.md
|
|
|
|
ARG BUILD_DATE
|
|
|
|
ARG REVISION
|
|
|
|
ARG VERSION
|
|
|
|
LABEL org.opencontainers.image.created="$BUILD_DATE" \
|
|
|
|
org.opencontainers.image.title="Joplin Server" \
|
|
|
|
org.opencontainers.image.description="Docker image for Joplin Server" \
|
|
|
|
org.opencontainers.image.url="https://joplinapp.org/" \
|
|
|
|
org.opencontainers.image.revision="$REVISION" \
|
|
|
|
org.opencontainers.image.source="https://github.com/laurent22/joplin.git" \
|
|
|
|
org.opencontainers.image.version="${VERSION}"
|