-
Notifications
You must be signed in to change notification settings - Fork 90
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
chore: docker builds optimizations #1795
Merged
Merged
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
647e974
Auth package dockerfile optimization
raducristianpopa e4dc1cf
Remove libc6-compat
raducristianpopa 6a5e410
Merge branch 'main' into rp--optimize-docker-builds
raducristianpopa eb1a2f8
Merge branch 'main' into rp--optimize-docker-builds
raducristianpopa fb4d02f
Remove test compose file
raducristianpopa 2b264c7
Backend dockerfile optimization
raducristianpopa bbbfbaa
Frontend and ASE Dockerfile optimizations
raducristianpopa 30cd458
Local HTTP Signatures app docker optimization
raducristianpopa 024c693
[Test] Bump PNPM major version
raducristianpopa 3ea267b
Use offline mode only for the build step
raducristianpopa 6895e39
Test out pnpm v8
raducristianpopa d3ff7b6
Add --prefer-offline option and revert pnpm to v7
raducristianpopa 321ff2a
Try out cache busting
raducristianpopa a0d8c84
Remove CACHE_BUST arg
raducristianpopa 439e808
Add `prefer-offline` options to all `prod-deps` stage
raducristianpopa e6c5fd7
Remove `--prefer-offline` from auth and backend Dockerfile
raducristianpopa 24ae203
Try installing TS globally
raducristianpopa 50a4315
Set PNPM_HOME in all docker files
raducristianpopa 7b39c57
Cache bust
raducristianpopa c815408
Revert "Cache bust"
raducristianpopa 292d063
Merge branch 'main' into rp--optimize-docker-builds
raducristianpopa 8ed59c2
Fetch `httpbis-digest-headers` from registry
raducristianpopa e5dd63c
Merge branch 'main' into rp--optimize-docker-builds
raducristianpopa 8627793
Bump `http-signature-utils` version
raducristianpopa b6577a8
Do not install TS globally when building prod deps
raducristianpopa ba69900
Make sure that `http-signature-utils` is bumped in every package
raducristianpopa 455b164
Pin alpine version
raducristianpopa 24db14d
Cache bust
raducristianpopa 1bfa0eb
Revert "Cache bust"
raducristianpopa 4a72018
Update pnpm to v8
raducristianpopa f5a0e05
Merge branch 'main' into rp--optimize-docker-builds
raducristianpopa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ infrastructure | |
|
||
.github | ||
.husky | ||
Dockerfile | ||
.dockerignore | ||
.eslintignore | ||
.eslintrc.yml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
FROM node:18.13.0-slim as builder | ||
FROM node:18-alpine3.18 AS base | ||
|
||
WORKDIR /workspace | ||
WORKDIR /home/rafiki | ||
|
||
RUN apt update | ||
RUN apt install -y curl xz-utils python3 build-essential | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# version in curl is not the version used. Dependent on the last command | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@7.25.1 --activate | ||
RUN corepack prepare pnpm@8.7.4 --activate | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
g++ | ||
|
||
# pnpm fetch does require only lockfile | ||
COPY pnpm-lock.yaml ./ | ||
RUN pnpm fetch | ||
|
||
ADD . ./ | ||
RUN pnpm install -r --offline | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm fetch \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS prod-deps | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc ./ | ||
COPY localenv/local-http-signatures/package.json ./localenv/local-http-signatures/package.json | ||
|
||
RUN pnpm clean | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--frozen-lockfile \ | ||
--prod \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS builder | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
COPY openapi ./openapi | ||
COPY localenv/local-http-signatures ./localenv/local-http-signatures | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--prefer-offline \ | ||
--offline \ | ||
--frozen-lockfile | ||
RUN pnpm --filter local-http-signatures build | ||
|
||
CMD ["node", "./localenv/local-http-signatures/dist/app.js"] | ||
FROM node:18-alpine3.18 AS runner | ||
|
||
WORKDIR /home/rafiki | ||
|
||
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules | ||
COPY --from=prod-deps /home/rafiki/localenv/local-http-signatures/node_modules ./localenv/local-http-signatures/node_modules | ||
COPY --from=prod-deps /home/rafiki/localenv/local-http-signatures/package.json ./localenv/local-http-signatures/package.json | ||
|
||
COPY --from=builder /home/rafiki/localenv/local-http-signatures/dist ./localenv/local-http-signatures/dist | ||
|
||
CMD ["node", "/home/rafiki/localenv/local-http-signatures/dist/app.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,62 @@ | ||
FROM node:18.13.0-slim as builder | ||
FROM node:18-alpine3.18 AS base | ||
|
||
WORKDIR /workspace | ||
WORKDIR /home/rafiki | ||
|
||
RUN apt update | ||
RUN apt install -y curl xz-utils python3 build-essential | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# version in curl is not the version used. Dependent on the last command | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@7.25.1 --activate | ||
RUN corepack prepare pnpm@8.7.4 --activate | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
g++ | ||
Comment on lines
+10
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
# pnpm fetch does require only lockfile | ||
COPY pnpm-lock.yaml ./ | ||
RUN pnpm fetch | ||
|
||
ADD . ./ | ||
RUN pnpm install -r --offline | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm fetch \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS prod-deps | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc ./ | ||
COPY localenv/mock-account-servicing-entity/package.json ./localenv/mock-account-servicing-entity/package.json | ||
|
||
RUN pnpm clean | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--prefer-offline \ | ||
--frozen-lockfile \ | ||
--prod \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS builder | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
COPY localenv/mock-account-servicing-entity ./localenv/mock-account-servicing-entity | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--offline \ | ||
--frozen-lockfile | ||
RUN pnpm --filter mock-account-servicing-entity build | ||
|
||
CMD pnpm --filter mock-account-servicing-entity start | ||
FROM node:18-alpine3.18 AS runner | ||
|
||
WORKDIR /home/rafiki | ||
|
||
COPY localenv/cloud-nine-wallet/seed.yml ./localenv/cloud-nine-wallet/seed.yml | ||
COPY localenv/happy-life-bank/seed.yml ./localenv/happy-life-bank/seed.yml | ||
|
||
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules | ||
COPY --from=prod-deps /home/rafiki/localenv/mock-account-servicing-entity/node_modules ./localenv/mock-account-servicing-entity/node_modules | ||
COPY --from=prod-deps /home/rafiki/localenv/mock-account-servicing-entity/package.json ./localenv/mock-account-servicing-entity/package.json | ||
|
||
COPY --from=builder /home/rafiki/localenv/mock-account-servicing-entity/build ./localenv/mock-account-servicing-entity/build | ||
COPY --from=builder /home/rafiki/localenv/mock-account-servicing-entity/public ./localenv/mock-account-servicing-entity/public | ||
|
||
WORKDIR /home/rafiki/localenv/mock-account-servicing-entity | ||
CMD ["sh", "./node_modules/.bin/remix-serve", "build"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
FROM node:18.13.0-slim as builder | ||
FROM node:18-alpine3.18 AS base | ||
|
||
WORKDIR /workspace | ||
WORKDIR /home/rafiki | ||
|
||
RUN apt update | ||
RUN apt install -y curl xz-utils python3 build-essential | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# version in curl is not the version used. Dependent on the last command | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@7.25.1 --activate | ||
RUN corepack prepare pnpm@8.7.4 --activate | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
g++ | ||
|
||
# pnpm fetch does require only lockfile | ||
COPY pnpm-lock.yaml ./ | ||
RUN pnpm fetch | ||
|
||
ADD . ./ | ||
RUN pnpm install -r --offline | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm fetch \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS prod-deps | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc ./ | ||
COPY packages/auth/package.json ./packages/auth/package.json | ||
COPY packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
|
||
RUN pnpm clean | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--prefer-offline \ | ||
--frozen-lockfile \ | ||
--prod \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS builder | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
COPY openapi ./openapi | ||
COPY packages/auth ./packages/auth | ||
COPY packages/token-introspection ./packages/token-introspection | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--offline \ | ||
--frozen-lockfile | ||
RUN pnpm --filter auth build | ||
|
||
CMD ["node", "./packages/auth/dist/index.js"] | ||
FROM node:18-alpine3.18 AS runner | ||
|
||
WORKDIR /home/rafiki | ||
|
||
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/auth/node_modules ./packages/auth/node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/auth/package.json ./packages/auth/package.json | ||
COPY --from=prod-deps /home/rafiki/packages/token-introspection/node_modules ./packages/token-introspection/node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
|
||
COPY --from=builder /home/rafiki/openapi ./openapi | ||
COPY --from=builder /home/rafiki/packages/auth/migrations/ ./packages/auth/migrations | ||
COPY --from=builder /home/rafiki/packages/token-introspection/src/openapi/token-introspection.yaml ./packages/token-introspection/src/openapi/token-introspection.yaml | ||
COPY --from=builder /home/rafiki/packages/auth/dist ./packages/auth/dist | ||
COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist | ||
|
||
|
||
CMD ["node", "/home/rafiki/packages/auth/dist/index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,67 @@ | ||
FROM node:18.13.0-slim as builder | ||
FROM node:18-alpine3.18 AS base | ||
|
||
WORKDIR /workspace | ||
WORKDIR /home/rafiki | ||
|
||
RUN apt update | ||
RUN apt install -y curl xz-utils python3 build-essential | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
|
||
# version in curl is not the version used. Dependent on the last command | ||
RUN corepack enable | ||
RUN corepack prepare pnpm@7.25.1 --activate | ||
RUN corepack prepare pnpm@8.7.4 --activate | ||
RUN apk add --no-cache \ | ||
python3 \ | ||
make \ | ||
g++ | ||
|
||
# pnpm fetch does require only lockfile | ||
COPY pnpm-lock.yaml ./ | ||
RUN pnpm fetch | ||
|
||
ADD . ./ | ||
RUN pnpm install -r --offline | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm fetch \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS prod-deps | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc ./ | ||
COPY packages/backend/package.json ./packages/backend/package.json | ||
COPY packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
|
||
RUN pnpm clean | ||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--prefer-offline \ | ||
--frozen-lockfile \ | ||
--prod \ | ||
| grep -v "cross-device link not permitted\|Falling back to copying packages from store" | ||
|
||
FROM base AS builder | ||
|
||
COPY package.json pnpm-workspace.yaml .npmrc tsconfig.json tsconfig.build.json ./ | ||
COPY openapi ./openapi | ||
COPY packages/backend ./packages/backend | ||
COPY packages/token-introspection ./packages/token-introspection | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--offline \ | ||
--frozen-lockfile | ||
RUN pnpm --filter backend build | ||
|
||
CMD ["node", "./packages/backend/dist/index.js"] | ||
FROM node:18-alpine3.18 AS runner | ||
|
||
WORKDIR /home/rafiki | ||
|
||
COPY --from=prod-deps /home/rafiki/node_modules ./node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/backend/node_modules ./packages/backend/node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/backend/package.json ./packages/backend/package.json | ||
COPY --from=prod-deps /home/rafiki/packages/token-introspection/node_modules ./packages/token-introspection/node_modules | ||
COPY --from=prod-deps /home/rafiki/packages/token-introspection/package.json ./packages/token-introspection/package.json | ||
|
||
COPY --from=builder /home/rafiki/openapi ./openapi | ||
COPY --from=builder /home/rafiki/packages/backend/migrations/ ./packages/backend/migrations | ||
COPY --from=builder /home/rafiki/packages/token-introspection/src/openapi/token-introspection.yaml ./packages/token-introspection/src/openapi/token-introspection.yaml | ||
COPY --from=builder /home/rafiki/packages/backend/dist ./packages/backend/dist | ||
COPY --from=builder /home/rafiki/packages/token-introspection/dist ./packages/token-introspection/dist | ||
|
||
|
||
CMD ["node", "/home/rafiki/packages/backend/dist/index.js"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed since I've added pnpm's version in the root
package.json
.rafiki/package.json
Lines 7 to 11 in 4a72018