mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-03 08:35:29 +02:00
3fcdeb08d9
- Removed complicated optimisation steps that didn't seem to optimise anything - Delete Yarn cache after installation After this, it should be back to the previous pre-Yarn size.
79 lines
2.9 KiB
Docker
79 lines
2.9 KiB
Docker
FROM node:16-bullseye
|
|
|
|
RUN apt-get update \
|
|
&& apt-get install -y \
|
|
python \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Enables Yarn
|
|
RUN corepack enable
|
|
|
|
RUN echo "Node: $(node --version)" \
|
|
&& echo "Npm: $(npm --version)" \
|
|
&& echo "Yarn: $(yarn --version)"
|
|
|
|
ARG user=joplin
|
|
|
|
RUN useradd --create-home --shell /bin/bash $user
|
|
USER $user
|
|
|
|
ENV NODE_ENV production
|
|
ENV RUNNING_IN_DOCKER 1
|
|
EXPOSE ${APP_PORT}
|
|
|
|
WORKDIR /home/$user
|
|
|
|
RUN mkdir /home/$user/logs \
|
|
&& mkdir /home/$user/.yarn
|
|
|
|
COPY --chown=$user:$user .yarn/patches ./.yarn/patches
|
|
COPY --chown=$user:$user .yarn/plugins ./.yarn/plugins
|
|
COPY --chown=$user:$user .yarn/releases ./.yarn/releases
|
|
COPY --chown=$user:$user package.json .
|
|
COPY --chown=$user:$user .yarnrc.yml .
|
|
COPY --chown=$user:$user yarn.lock .
|
|
COPY --chown=$user:$user gulpfile.js .
|
|
COPY --chown=$user:$user tsconfig.json .
|
|
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
|
|
COPY --chown=$user:$user packages/server/package*.json ./packages/server/
|
|
COPY --chown=$user:$user packages/fork-sax ./packages/fork-sax
|
|
COPY --chown=$user:$user packages/fork-uslug ./packages/fork-uslug
|
|
COPY --chown=$user:$user packages/htmlpack ./packages/htmlpack
|
|
COPY --chown=$user:$user packages/renderer ./packages/renderer
|
|
COPY --chown=$user:$user packages/tools ./packages/tools
|
|
COPY --chown=$user:$user packages/lib ./packages/lib
|
|
COPY --chown=$user:$user packages/server ./packages/server
|
|
|
|
# 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.
|
|
|
|
RUN BUILD_SEQUENCIAL=1 yarn install --inline-builds \
|
|
&& yarn cache clean \
|
|
&& rm -rf .yarn/berry
|
|
|
|
# Call the command directly, without going via npm:
|
|
# https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#cmd
|
|
WORKDIR "/home/$user/packages/server"
|
|
CMD [ "node", "dist/app.js" ]
|
|
|
|
# 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}"
|