Files
backstage/packages/backend/Dockerfile
T
Patrick Jungermann 05f584f84d feat: add documented component to uffizzi environment
So far, none of the components at the uffizzi environment have techdocs.
Hence, there are no docs available within this environment
and related features are not covered.

This change will add an example from techdocs-backend plugin
to the deployed examples.

It was possible to register this catalog file manually,
however the build of the docs fail due to missing Docker.

To allow the generation of docs, we use the local generator
(no docker in docker) and install required dependencies.

As we don't want all dependencies for all (default) extensions
to be installed at this environment, the original example at
techdocs-backend plugin was copied and reduced
(PlantUML extension example was removed).

Signed-off-by: Patrick Jungermann <Patrick.Jungermann@gmail.com>
2023-05-12 12:03:46 +02:00

53 lines
2.3 KiB
Docker

# This dockerfile builds an image for the backend package.
# It should be executed with the root of the repo as docker context.
#
# Before building this image, be sure to have run the following commands in the repo root:
#
# yarn install
# yarn tsc
# yarn build:backend
#
# Once the commands have been run, you can build the image using `yarn build-image`
FROM node:16-bullseye-slim
# Install sqlite3 dependencies. You can skip this if you don't use sqlite3 in the image,
# in which case you should also move better-sqlite3 to "devDependencies" in package.json.
# Additionally, we install dependencies for `techdocs.generator.runIn: local`.
# https://backstage.io/docs/features/techdocs/getting-started#disabling-docker-in-docker-situation-optional
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
apt-get update && \
apt-get install -y --no-install-recommends libsqlite3-dev python3 python3-pip build-essential && \
yarn config set python /usr/bin/python3 && \
pip3 install mkdocs-techdocs-core==1.1.7
# From here on we use the least-privileged `node` user to run the backend.
WORKDIR /app
RUN chown node:node /app
USER node
# This switches many Node.js dependencies to production mode.
ENV NODE_ENV production
# Copy over Yarn 3 configuration, release, and plugins
COPY --chown=node:node .yarn ./.yarn
COPY --chown=node:node .yarnrc.yml ./
# Copy repo skeleton first, to avoid unnecessary docker cache invalidation.
# The skeleton contains the package.json of each package in the monorepo,
# and along with yarn.lock and the root package.json, that's enough to run yarn install.
COPY --chown=node:node yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./
RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz
# Note that this install is not immutable, which is one of the reasons we don't recommend Yarn 3 yet
RUN --mount=type=cache,target=/home/node/.yarn/berry/cache,sharing=locked,uid=1000,gid=1000 \
yarn workspaces focus --all --production
# Then copy the rest of the backend bundle, along with any other files we might want.
COPY --chown=node:node packages/backend/dist/bundle.tar.gz app-config*.yaml ./
RUN tar xzf bundle.tar.gz && rm bundle.tar.gz
CMD ["node", "packages/backend", "--config", "app-config.yaml"]