diff --git a/.changeset/honest-kids-live.md b/.changeset/honest-kids-live.md new file mode 100644 index 0000000000..e829d00d91 --- /dev/null +++ b/.changeset/honest-kids-live.md @@ -0,0 +1,7 @@ +--- +'@backstage/create-app': patch +--- + +Optimized the command order in `packages/backend/Dockerfile` as well as added the `--no-install-recommends` to the `apt-get install` and tweaked the installed packages. + +To apply this change to an existing app, update your `packages/backend/Dockerfile` to match the documented `Dockerfile` at https://backstage.io/docs/deployment/docker#host-build. diff --git a/docs/deployment/docker.md b/docs/deployment/docker.md index 0b99e81d64..01bc6279f2 100644 --- a/docs/deployment/docker.md +++ b/docs/deployment/docker.md @@ -59,18 +59,19 @@ Once the host build is complete, we are ready to build our image. The following FROM node:16-bullseye-slim WORKDIR /app + +# install sqlite3 dependencies, you can skip this if you don't use sqlite3 in the image +RUN apt-get update && \ + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + # 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 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. @@ -159,7 +160,8 @@ WORKDIR /app COPY --from=packages /app . # install sqlite3 dependencies -RUN apt-get update && apt-get install -y libsqlite3-dev python3 cmake g++ && \ +RUN apt-get update && \ + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ yarn config set python /usr/bin/python3 RUN yarn install --frozen-lockfile --network-timeout 600000 && rm -rf "$(yarn cache dir)" @@ -176,16 +178,16 @@ FROM node:16-bullseye-slim WORKDIR /app +# install sqlite3 dependencies, you can skip this if you don't use sqlite3 in the image +RUN apt-get update && \ + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + # Copy the install dependencies from the build stage and context 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/packages/backend/Dockerfile b/packages/backend/Dockerfile index dd35d4ddbc..86f6e17861 100644 --- a/packages/backend/Dockerfile +++ b/packages/backend/Dockerfile @@ -13,18 +13,18 @@ FROM node:16-bullseye-slim WORKDIR /app +# install sqlite3 dependencies, you can skip this if you don't use sqlite3 in the image +RUN apt-get update && \ + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + # 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 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 dd35d4ddbc..86f6e17861 100644 --- a/packages/create-app/templates/default-app/packages/backend/Dockerfile +++ b/packages/create-app/templates/default-app/packages/backend/Dockerfile @@ -13,18 +13,18 @@ FROM node:16-bullseye-slim WORKDIR /app +# install sqlite3 dependencies, you can skip this if you don't use sqlite3 in the image +RUN apt-get update && \ + apt-get install -y --no-install-recommends libsqlite3-dev python3 build-essential && \ + rm -rf /var/lib/apt/lists/* && \ + yarn config set python /usr/bin/python3 + # 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 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.