diff --git a/.changeset/young-guests-confess.md b/.changeset/young-guests-confess.md new file mode 100644 index 0000000000..c27c99c147 --- /dev/null +++ b/.changeset/young-guests-confess.md @@ -0,0 +1,28 @@ +--- +'@backstage/create-app': patch +--- + +To reflect the updated `knex` and `@vscode/sqlite3` dependencies introduced with [v0.4.19](https://github.com/backstage/backstage/blob/master/packages/create-app/CHANGELOG.md#0419), we update our example `Dockerfile`, adding `@vscode/sqlite3` build dependencies to the image. Further on, we updated it to the `node:16-bullseye-slim` base image. + +To apply this update to an existing app, make the following change to `packages/backend/Dockerfile`: + +```diff +-FROM node:14-buster-slim ++FROM node:16-bullseye-slim +``` + +and, _only if you are using sqlite3 in your app_: + +```diff +RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz ++ ++# install sqlite3 dependencies ++RUN apt-get update && \ ++ apt-get install -y libsqlite3-dev python3 cmake g++ && \ ++ rm -rf /var/lib/apt/lists/* && \ ++ yarn config set python /usr/bin/python3 + +RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" +``` + +If you are using a multi-stage Docker build for your app, please refer to the [updated examples](https://github.com/backstage/backstage/blob/master/docs/deployment/docker.md#multi-stage-build) in the documentation. diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md index 6f58abe769..36967f352a 100644 --- a/docs/deployment/docker.md +++ b/docs/deployment/docker.md @@ -56,7 +56,7 @@ Once the host build is complete, we are ready to build our image. The following `Dockerfile` is included when creating a new app with `@backstage/create-app`: ```Dockerfile -FROM node:14-buster-slim +FROM node:16-bullseye-slim WORKDIR /app # Copy repo skeleton first, to avoid unnecessary docker cache invalidation. @@ -65,6 +65,12 @@ WORKDIR /app COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz +# install sqlite3 dependencies +RUN apt-get update && \ + apt-get install -y libsqlite3-dev python3 cmake g++ && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" # Then copy the rest of the backend bundle, along with any other files we might want. @@ -134,23 +140,28 @@ the repo root: ```Dockerfile # Stage 1 - Create yarn install skeleton layer -FROM node:14-buster-slim AS packages +FROM node:16-bullseye-slim AS packages WORKDIR /app COPY package.json yarn.lock ./ COPY packages packages + # Comment this out if you don't have any internal plugins COPY plugins plugins RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -exec rm -rf {} \+ # Stage 2 - Install dependencies and build packages -FROM node:14-buster-slim AS build +FROM node:16-bullseye-slim AS build WORKDIR /app COPY --from=packages /app . +# install sqlite3 dependencies +RUN apt-get update && apt-get install -y libsqlite3-dev python3 cmake g++ && \ + yarn config set python /usr/bin/python3 + RUN yarn install --frozen-lockfile --network-timeout 600000 && rm -rf "$(yarn cache dir)" COPY . . @@ -159,7 +170,7 @@ RUN yarn tsc RUN yarn --cwd packages/backend backstage-cli backend:bundle --build-dependencies # Stage 3 - Build the actual backend image and install production dependencies -FROM node:14-buster-slim +FROM node:16-bullseye-slim WORKDIR /app @@ -167,6 +178,12 @@ WORKDIR /app COPY --from=build /app/yarn.lock /app/package.json /app/packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz +# install sqlite3 dependencies +RUN apt-get update && \ + apt-get install -y libsqlite3-dev python3 cmake g++ && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + RUN yarn install --frozen-lockfile --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" # Copy the built packages from the build stage diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index c4a08afc56..75f0606752 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -334,13 +334,19 @@ The following is an example of a `Dockerfile` that can be used to package the output of `backstage-cli backend:bundle` into an image: ```Dockerfile -FROM node:14-buster-slim +FROM node:16-bullseye-slim WORKDIR /app COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz -RUN yarn install --production --frozen-lockfile --network-timeout 300000 && rm -rf "$(yarn cache dir)" +# install sqlite3 dependencies +RUN apt-get update && \ + apt-get install -y libsqlite3-dev python3 cmake g++ && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + +RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" COPY packages/backend/dist/bundle.tar.gz app-config.yaml ./ RUN tar xzf bundle.tar.gz && rm bundle.tar.gz diff --git a/packages/backend/Dockerfile b/packages/backend/Dockerfile index 31231a3a4a..dd35d4ddbc 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -9,7 +9,7 @@ # # Once the commands have been run, you can build the image using `yarn build-image` -FROM node:14-buster-slim +FROM node:16-bullseye-slim WORKDIR /app @@ -19,6 +19,12 @@ WORKDIR /app COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz +# install sqlite3 dependencies +RUN apt-get update && \ + apt-get install -y libsqlite3-dev python3 cmake g++ && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" # Then copy the rest of the backend bundle, along with any other files we might want. diff --git a/packages/create-app/templates/default-app/packages/backend/Dockerfile b/packages/create-app/templates/default-app/packages/backend/Dockerfile index 31231a3a4a..dd35d4ddbc 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -9,7 +9,7 @@ # # Once the commands have been run, you can build the image using `yarn build-image` -FROM node:14-buster-slim +FROM node:16-bullseye-slim WORKDIR /app @@ -19,6 +19,12 @@ WORKDIR /app COPY yarn.lock package.json packages/backend/dist/skeleton.tar.gz ./ RUN tar xzf skeleton.tar.gz && rm skeleton.tar.gz +# install sqlite3 dependencies +RUN apt-get update && \ + apt-get install -y libsqlite3-dev python3 cmake g++ && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + RUN yarn install --frozen-lockfile --production --network-timeout 300000 && rm -rf "$(yarn cache dir)" # Then copy the rest of the backend bundle, along with any other files we might want.