From a797a59a6c52698e43f3e2059bc381cb3852b309 Mon Sep 17 00:00:00 2001 From: Shashank Budhanuru Ramaraju Date: Fri, 27 Sep 2024 00:44:16 +0100 Subject: [PATCH 1/4] use node alpine and fix Mac issue --- Dockerfile | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index f83bcd29b..8489fbdaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,31 +1,35 @@ # syntax=docker/dockerfile:1 -FROM node:18 AS setup +FROM node:18-alpine AS build WORKDIR /app + COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/ .yarn/ COPY packages/ packages/ -RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete && \ -find . -type d -empty -delete - -FROM node:18 AS build -WORKDIR /app -COPY --from=setup /app . +RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete +RUN find . -type d -empty -delete RUN yarn install --immutable COPY . . WORKDIR /app/packages/apollo-collaboration-server RUN yarn build -FROM node:18 -LABEL org.opencontainers.image.source=https://github.com/GMOD/Apollo3 -LABEL org.opencontainers.image.description="Apollo collaboration server" +FROM node:18-alpine WORKDIR /app -COPY --from=setup /app . COPY --from=build /app/packages/apollo-collaboration-server/dist /app/packages/apollo-collaboration-server/dist COPY --from=build /app/packages/apollo-common/dist /app/packages/apollo-common/dist COPY --from=build /app/packages/apollo-mst/dist /app/packages/apollo-mst/dist COPY --from=build /app/packages/apollo-schemas/dist /app/packages/apollo-schemas/dist COPY --from=build /app/packages/apollo-shared/dist /app/packages/apollo-shared/dist +COPY --from=build /app/packages/apollo-shared/package.json /app/packages/apollo-shared/package.json +COPY --from=build /app/packages/apollo-schemas/package.json /app/packages/apollo-schemas/package.json +COPY --from=build /app/packages/apollo-mst/package.json /app/packages/apollo-mst/package.json +COPY --from=build /app/packages/apollo-common/package.json /app/packages/apollo-common/package.json +COPY --from=build /app/packages/apollo-collaboration-server/package.json /app/packages/apollo-collaboration-server/package.json +COPY --from=build /app/package.json /app/package.json +COPY --from=build /app/yarn.lock /app/yarn.lock +COPY --from=build /app/.yarnrc.yml /app/.yarnrc.yml +COPY --from=build /app/.yarn/ /app/.yarn/ RUN yarn workspaces focus --production @apollo-annotation/collaboration-server + EXPOSE 3999 CMD ["yarn", "start:prod"] From f5c09d076fd72fee0b3d14c1912f790acea0a66d Mon Sep 17 00:00:00 2001 From: Shashank Budhanuru Ramaraju Date: Wed, 2 Oct 2024 12:08:06 +0100 Subject: [PATCH 2/4] Dockerfile add label and three stages --- Dockerfile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8489fbdaa..a0e7abfe6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,24 @@ # syntax=docker/dockerfile:1 -FROM node:18-alpine AS build +FROM node:18-alpine AS setup WORKDIR /app - COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/ .yarn/ COPY packages/ packages/ RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete RUN find . -type d -empty -delete + +FROM node:18-alpine AS build +WORKDIR /app +COPY --from=setup /app . RUN yarn install --immutable COPY . . WORKDIR /app/packages/apollo-collaboration-server RUN yarn build FROM node:18-alpine +LABEL org.opencontainers.image.source=https://github.com/GMOD/Apollo3 +LABEL org.opencontainers.image.description="Apollo collaboration server" WORKDIR /app COPY --from=build /app/packages/apollo-collaboration-server/dist /app/packages/apollo-collaboration-server/dist COPY --from=build /app/packages/apollo-common/dist /app/packages/apollo-common/dist From 92f08fd96ae5eda0013ce93d3d7d953e43a7fe2f Mon Sep 17 00:00:00 2001 From: Shashank Budhanuru Ramaraju Date: Wed, 2 Oct 2024 13:05:38 +0100 Subject: [PATCH 3/4] change base image to node:18-alpine --- Dockerfile | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index a0e7abfe6..28c287595 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,8 +5,8 @@ WORKDIR /app COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/ .yarn/ COPY packages/ packages/ -RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete -RUN find . -type d -empty -delete +RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete && \ +find . -type d -empty -delete FROM node:18-alpine AS build WORKDIR /app @@ -20,21 +20,12 @@ FROM node:18-alpine LABEL org.opencontainers.image.source=https://github.com/GMOD/Apollo3 LABEL org.opencontainers.image.description="Apollo collaboration server" WORKDIR /app +COPY --from=setup /app . COPY --from=build /app/packages/apollo-collaboration-server/dist /app/packages/apollo-collaboration-server/dist COPY --from=build /app/packages/apollo-common/dist /app/packages/apollo-common/dist COPY --from=build /app/packages/apollo-mst/dist /app/packages/apollo-mst/dist COPY --from=build /app/packages/apollo-schemas/dist /app/packages/apollo-schemas/dist COPY --from=build /app/packages/apollo-shared/dist /app/packages/apollo-shared/dist -COPY --from=build /app/packages/apollo-shared/package.json /app/packages/apollo-shared/package.json -COPY --from=build /app/packages/apollo-schemas/package.json /app/packages/apollo-schemas/package.json -COPY --from=build /app/packages/apollo-mst/package.json /app/packages/apollo-mst/package.json -COPY --from=build /app/packages/apollo-common/package.json /app/packages/apollo-common/package.json -COPY --from=build /app/packages/apollo-collaboration-server/package.json /app/packages/apollo-collaboration-server/package.json -COPY --from=build /app/package.json /app/package.json -COPY --from=build /app/yarn.lock /app/yarn.lock -COPY --from=build /app/.yarnrc.yml /app/.yarnrc.yml -COPY --from=build /app/.yarn/ /app/.yarn/ RUN yarn workspaces focus --production @apollo-annotation/collaboration-server - EXPOSE 3999 CMD ["yarn", "start:prod"] From 1e8adbe329f8932af92f23c361a3e6f4723e7c46 Mon Sep 17 00:00:00 2001 From: Shashank Budhanuru Ramaraju Date: Mon, 7 Oct 2024 13:38:59 +0100 Subject: [PATCH 4/4] node:20-alpine base image --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 28c287595..aac46f6ce 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # syntax=docker/dockerfile:1 -FROM node:18-alpine AS setup +FROM node:20-alpine AS setup WORKDIR /app COPY package.json yarn.lock .yarnrc.yml ./ COPY .yarn/ .yarn/ @@ -8,7 +8,7 @@ COPY packages/ packages/ RUN find packages/ -type f \! \( -name "package.json" -o -name "yarn.lock" \) -delete && \ find . -type d -empty -delete -FROM node:18-alpine AS build +FROM node:20-alpine AS build WORKDIR /app COPY --from=setup /app . RUN yarn install --immutable @@ -16,7 +16,7 @@ COPY . . WORKDIR /app/packages/apollo-collaboration-server RUN yarn build -FROM node:18-alpine +FROM node:20-alpine LABEL org.opencontainers.image.source=https://github.com/GMOD/Apollo3 LABEL org.opencontainers.image.description="Apollo collaboration server" WORKDIR /app