Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base images version bump. Builds time optimization #4338

Merged
merged 1 commit into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions ai-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,9 +39,10 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/yarn.lock ./
COPY --link ai-service/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:prod
yarn install --immutable
COPY --link ai-service/src src/
RUN yarn run build:prod

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions analytics-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,9 +39,10 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/yarn.lock ./
COPY --link analytics-service/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:prod
yarn install --immutable
COPY --link analytics-service/src src/
RUN yarn run build:prod

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,10 +39,11 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable
COPY --link api-gateway/environments environments/
COPY --link api-gateway/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:prod
RUN yarn run build:prod

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions api-gateway/Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,10 +39,11 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable
COPY --link api-gateway/environments environments/
COPY --link api-gateway/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:demo
RUN yarn run build:demo

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions application-events/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,9 +39,10 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/yarn.lock ./
COPY --link application-events/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:prod
yarn install --immutable
COPY --link application-events/src src/
RUN yarn run build:prod

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions auth-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,10 +39,11 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable
COPY --link auth-service/environments environments/
COPY --link auth-service/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:prod
RUN yarn run build:prod

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
19 changes: 11 additions & 8 deletions auth-service/Dockerfile.demo
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
# Stage 0: Use node image for base image for all stages
ARG NODE_VERSION=20.17-alpine
ARG NODE_VERSION=20.18-alpine
FROM --platform=$BUILDPLATFORM node:${NODE_VERSION} AS base
WORKDIR /usr/local/app
# Define an argument `YARN_CACHE_FOLDER` for the Yarn cache directory
Expand All @@ -9,19 +9,21 @@ ARG YARN_CACHE_FOLDER=/root/.yarn
# Stage 1: Build interfaces module
FROM base AS interfaces
COPY --link interfaces/package.json interfaces/tsconfig*.json yarn.lock ./
COPY --link interfaces/src src/
# Here and after. Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
# Leverage a cache mount to `YARN_CACHE_FOLDER` to speed up subsequent builds
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install --immutable && yarn pack
yarn install --immutable
COPY --link interfaces/src src/
RUN yarn pack

# Stage 2: Build common module
FROM base AS common
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link common/package.json common/tsconfig*.json yarn.lock ./
COPY --link common/src src/
RUN node -e "const fs=require('fs'); const input=JSON.parse(fs.readFileSync('package.json')); input.dependencies['@guardian/interfaces']='file:/tmp/interfaces.tgz'; fs.writeFileSync('package.json', JSON.stringify(input));"
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER} \
yarn install && yarn pack
yarn install
COPY --link common/src src/
RUN yarn pack

# Stage 3: Installing production dependecies
FROM base AS deps
Expand All @@ -37,10 +39,11 @@ FROM base AS build
COPY --link --from=interfaces /usr/local/app/guardian-interfaces-*.tgz /tmp/interfaces.tgz
COPY --link --from=common /usr/local/app/guardian-common-*.tgz /tmp/common.tgz
COPY --link --from=deps /usr/local/app/package.json /usr/local/app/tsconfig*.json /usr/local/app/Gulpfile.mjs /usr/local/app/yarn.lock ./
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable
COPY --link auth-service/environments environments/
COPY --link auth-service/src src/
RUN --mount=type=cache,target=${YARN_CACHE_FOLDER},sharing=private \
yarn install --immutable && yarn run build:demo
RUN yarn run build:demo

# Stage 5: Create the final image
FROM node:${NODE_VERSION} AS image
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:
# - seq_data:/data

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0
ports:
- "5001:5001"
- "4001:4001"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-indexer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- mongo

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0

message-broker:
image: nats:2.9.25
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-indexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ services:
- mongo

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0

message-broker:
image: nats:2.9.25
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-production-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
# - seq_data:/data

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0
ports:
- "5001:5001"
- "4001:4001"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ services:
# - seq_data:/data

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0
ports:
- "5001:5001"
- "4001:4001"
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ services:
# - seq_data:/data

ipfs-node:
image: ipfs/kubo:v0.29.0
image: ipfs/kubo:v0.31.0
ports:
- "5001:5001"
- "4001:4001"
Expand Down
Loading
Loading