2021-08-23 10:51:26 +02:00
|
|
|
FROM node:16-bullseye
|
|
|
|
|
|
|
|
RUN apt-get update \
|
|
|
|
&& apt-get install -y \
|
|
|
|
python \
|
|
|
|
&& 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
|
|
|
|
|
2021-08-13 19:59:45 +02:00
|
|
|
RUN echo "Node: $(node --version)"
|
|
|
|
RUN echo "Npm: $(npm --version)"
|
2021-12-20 17:08:43 +02:00
|
|
|
RUN echo "Yarn: $(yarn --version)"
|
2021-08-13 19:59:45 +02:00
|
|
|
|
2020-12-28 13:48:47 +02:00
|
|
|
ARG user=joplin
|
|
|
|
|
|
|
|
RUN useradd --create-home --shell /bin/bash $user
|
|
|
|
USER $user
|
|
|
|
|
|
|
|
ENV NODE_ENV development
|
|
|
|
|
|
|
|
WORKDIR /home/$user
|
|
|
|
|
|
|
|
RUN mkdir /home/$user/logs
|
|
|
|
|
2021-01-18 12:13:26 +02:00
|
|
|
# Install the root scripts but don't run postinstall (which would bootstrap
|
|
|
|
# and build TypeScript files, but we don't have the TypeScript files at
|
|
|
|
# this point)
|
|
|
|
|
|
|
|
COPY --chown=$user:$user package*.json ./
|
2021-12-20 17:08:43 +02:00
|
|
|
COPY --chown=$user:$user .yarn ./.yarn
|
|
|
|
COPY --chown=$user:$user .yarnrc.yml .
|
|
|
|
COPY --chown=$user:$user yarn.lock .
|
|
|
|
|
|
|
|
RUN yarn install --inline-builds --mode=skip-build
|
2021-01-18 12:13:26 +02:00
|
|
|
|
2020-12-28 13:48:47 +02:00
|
|
|
# To take advantage of the Docker cache, we first copy all the package.json
|
2021-01-18 12:13:26 +02:00
|
|
|
# and package-lock.json files, as they rarely change, and then bootstrap
|
2020-12-28 13:48:47 +02:00
|
|
|
# all the packages.
|
|
|
|
#
|
|
|
|
# Note that bootstrapping the packages will run all the postinstall
|
|
|
|
# scripts, which means that for packages that have such scripts, we need to
|
|
|
|
# copy all the files.
|
|
|
|
#
|
|
|
|
# We can't run boostrap with "--ignore-scripts" because that would
|
|
|
|
# prevent certain sub-packages, such as sqlite3, from being built
|
|
|
|
|
|
|
|
COPY --chown=$user:$user packages/fork-sax/package*.json ./packages/fork-sax/
|
2021-12-20 17:08:43 +02:00
|
|
|
COPY --chown=$user:$user packages/fork-uslug/package*.json ./packages/fork-uslug/
|
2021-11-23 18:09:09 +02:00
|
|
|
COPY --chown=$user:$user packages/htmlpack/package*.json ./packages/htmlpack/
|
2020-12-28 13:48:47 +02:00
|
|
|
COPY --chown=$user:$user packages/renderer/package*.json ./packages/renderer/
|
|
|
|
COPY --chown=$user:$user packages/tools/package*.json ./packages/tools/
|
2021-01-18 12:13:26 +02:00
|
|
|
COPY --chown=$user:$user packages/lib/package*.json ./packages/lib/
|
2020-12-28 13:48:47 +02:00
|
|
|
COPY --chown=$user:$user tsconfig.json .
|
|
|
|
|
|
|
|
# The following have postinstall scripts so we need to copy all the files.
|
|
|
|
# Since they should rarely change this is not an issue
|
|
|
|
|
|
|
|
COPY --chown=$user:$user packages/turndown ./packages/turndown
|
|
|
|
COPY --chown=$user:$user packages/turndown-plugin-gfm ./packages/turndown-plugin-gfm
|
|
|
|
COPY --chown=$user:$user packages/fork-htmlparser2 ./packages/fork-htmlparser2
|
2021-12-20 17:08:43 +02:00
|
|
|
COPY --chown=$user:$user packages/server/package*.json ./packages/server/
|
2020-12-28 13:48:47 +02:00
|
|
|
|
|
|
|
# Then bootstrap only, without compiling the TypeScript files
|
|
|
|
|
2021-12-20 17:08:43 +02:00
|
|
|
RUN yarn install --inline-builds --mode=skip-build
|
2021-01-18 12:13:26 +02:00
|
|
|
|
2021-10-23 22:57:45 +02:00
|
|
|
# Now copy the source files. Put lib and server last as they are more likely to change.
|
2021-01-18 12:13:26 +02:00
|
|
|
|
2020-12-28 13:48:47 +02:00
|
|
|
COPY --chown=$user:$user packages/fork-sax ./packages/fork-sax
|
2021-12-20 17:08:43 +02:00
|
|
|
COPY --chown=$user:$user packages/fork-uslug ./packages/fork-uslug
|
2021-11-23 18:09:09 +02:00
|
|
|
COPY --chown=$user:$user packages/htmlpack ./packages/htmlpack
|
2020-12-28 13:48:47 +02:00
|
|
|
COPY --chown=$user:$user packages/renderer ./packages/renderer
|
|
|
|
COPY --chown=$user:$user packages/tools ./packages/tools
|
2021-01-18 12:13:26 +02:00
|
|
|
COPY --chown=$user:$user packages/lib ./packages/lib
|
2021-10-23 22:57:45 +02:00
|
|
|
COPY --chown=$user:$user packages/server ./packages/server
|
2020-12-28 13:48:47 +02:00
|
|
|
|
|
|
|
# Finally build everything, in particular the TypeScript files.
|
|
|
|
|
2021-12-20 17:08:43 +02:00
|
|
|
RUN yarn run build
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2021-01-18 12:13:26 +02:00
|
|
|
ENV RUNNING_IN_DOCKER=1
|
|
|
|
EXPOSE ${APP_PORT}
|
2020-12-28 13:48:47 +02:00
|
|
|
|
2021-12-20 17:08:43 +02:00
|
|
|
CMD [ "yarn", "--prefix", "packages/server", "start" ]
|
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}"
|