diff --git a/.changeset/sweet-cameras-kick.md b/.changeset/sweet-cameras-kick.md new file mode 100644 index 0000000000..5c6b9162b9 --- /dev/null +++ b/.changeset/sweet-cameras-kick.md @@ -0,0 +1,5 @@ +--- +'@backstage/create-app': patch +--- + +Updated included Dockerfile to include `g++`. Also updated the comments to note that some of the dependencies are also needed by isolated-vm diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md index f96204b413..dc436129c5 100644 --- a/docs/deployment/docker.md +++ b/docs/deployment/docker.md @@ -37,7 +37,7 @@ The required steps in the host build are to install dependencies with `yarn install`, generate type definitions using `yarn tsc`, and build the backend package with `yarn build:backend`. -In a CI workflow it might look something like this: +In a CI workflow it might look something like this, from the root: ```bash yarn install --frozen-lockfile @@ -47,7 +47,7 @@ yarn tsc # Build the backend, which bundles it all up into the packages/backend/dist folder. # The configuration files here should match the one you use inside the Dockerfile below. -yarn build:backend --config app-config.yaml +yarn build:backend --config ../../app-config.yaml ``` Once the host build is complete, we are ready to build our image. The following @@ -56,13 +56,18 @@ Once the host build is complete, we are ready to build our image. The following ```Dockerfile FROM node:16-bullseye-slim +# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend. +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 python3 g++ build-essential && \ + yarn config set python /usr/bin/python3 + # 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. 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 build-essential && \ - yarn config set python /usr/bin/python3 + apt-get install -y --no-install-recommends libsqlite3-dev # From here on we use the least-privileged `node` user to run the backend. USER node @@ -169,13 +174,19 @@ RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf { # Stage 2 - Install dependencies and build packages FROM node:16-bullseye-slim AS build -# install sqlite3 dependencies +# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend. 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 build-essential && \ + apt-get install -y --no-install-recommends python3 g++ build-essential && \ yarn config set python /usr/bin/python3 +# 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. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get install -y --no-install-recommends libsqlite3-dev + USER node WORKDIR /app @@ -200,13 +211,18 @@ RUN mkdir packages/backend/dist/skeleton packages/backend/dist/bundle \ # Stage 3 - Build the actual backend image and install production dependencies FROM node:16-bullseye-slim +# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend. +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 python3 g++ build-essential && \ + yarn config set python /usr/bin/python3 + # 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. 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 build-essential && \ - yarn config set python /usr/bin/python3 + apt-get install -y --no-install-recommends libsqlite3-dev # From here on we use the least-privileged `node` user to run the backend. USER node diff --git a/packages/create-app/templates/default-app/packages/backend/Dockerfile b/packages/create-app/templates/default-app/packages/backend/Dockerfile index 51f7124db4..d065e4a248 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -11,13 +11,18 @@ FROM node:16-bullseye-slim +# Install isolate-vm dependencies, these are needed by the @backstage/plugin-scaffolder-backend. +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 python3 g++ build-essential && \ + yarn config set python /usr/bin/python3 + # 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. 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 build-essential && \ - yarn config set python /usr/bin/python3 + apt-get install -y --no-install-recommends libsqlite3-dev # From here on we use the least-privileged `node` user to run the backend. USER node