-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Local HTTP Signatures app docker optimization
- Loading branch information
1 parent
bbbfbaa
commit 30cd458
Showing
1 changed file
with
45 additions
and
11 deletions.
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 |
---|---|---|
@@ -1,21 +1,55 @@ | ||
FROM node:18.13.0-slim as builder | ||
FROM node:18-alpine AS base | ||
|
||
WORKDIR /workspace | ||
WORKDIR /home/rafiki | ||
|
||
RUN apt update | ||
RUN apt install -y curl xz-utils python3 build-essential | ||
|
||
# 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 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=/root/.local/share/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=/root/.local/share/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--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 localenv/local-http-signatures ./localenv/local-http-signatures | ||
|
||
RUN --mount=type=cache,id=pnpm,target=/root/.local/share/pnpm/store \ | ||
pnpm install \ | ||
--recursive \ | ||
--offline \ | ||
--frozen-lockfile | ||
RUN pnpm --filter local-http-signatures build | ||
|
||
CMD ["node", "./localenv/local-http-signatures/dist/app.js"] | ||
FROM node:18-alpine 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"] |