From 6327bb8770a78c8696928d885c8f302cfc70cbc9 Mon Sep 17 00:00:00 2001 From: blam Date: Tue, 26 Jan 2021 13:33:56 +0100 Subject: [PATCH] chore: Added example multi-stage with the new backstage bundle command --- .../docker/multi-stage-with-bundle/Dockerfile | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 contrib/docker/multi-stage-with-bundle/Dockerfile diff --git a/contrib/docker/multi-stage-with-bundle/Dockerfile b/contrib/docker/multi-stage-with-bundle/Dockerfile new file mode 100644 index 0000000000..5e6ce770de --- /dev/null +++ b/contrib/docker/multi-stage-with-bundle/Dockerfile @@ -0,0 +1,42 @@ +# Stage 1 - Create yarn install skeleton layer +FROM node:14-buster AS packages + +WORKDIR /app +COPY package.json yarn.lock ./ + +# Uncomment this line if building a non create-app version +# COPY packages packages +COPY plugins plugins + +RUN find packages \! -name "package.json" -mindepth 2 -maxdepth 2 -print | xargs rm -rf + +# Stage 2 - Install dependencies and build packages +FROM node:14-buster AS build + +WORKDIR /app +COPY --from=packages /app . + +RUN yarn install --network-timeout 600000 && rm -rf "$(yarn cache dir)" + +COPY . . + +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 + +WORKDIR /app + +# Copy from build stage +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 + +RUN yarn install --production --network-timeout 600000 && rm -rf "$(yarn cache dir)" + +COPY --from=build /app/packages/backend/dist/bundle.tar.gz . +RUN tar xzf bundle.tar.gz && rm bundle.tar.gz + +COPY app-config.yaml app-config.production.yaml ./ + +CMD ["node", "packages/backend", "--config", "app-config.yaml", "--config", "app-config.production.yaml"] \ No newline at end of file