-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: switch package manager from npm to pnpm
Signed-off-by: Mogyuchi <[email protected]>
- Loading branch information
Showing
9 changed files
with
2,934 additions
and
4,785 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
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 +1,13 @@ | ||
use-node-version=20.10.0 | ||
|
||
save-exact=true | ||
auto-install-peers=true | ||
strict-peer-dependencies=true | ||
|
||
shell-emulator=true | ||
|
||
update-notifier=false | ||
|
||
; npm の使用を防ぐ | ||
engine-strict=true | ||
package-lock-only=true |
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,3 +1,3 @@ | ||
{ | ||
"pre-commit": "npx lint-staged" | ||
"pre-commit": "pnpm exec lint-staged" | ||
} |
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,33 +1,69 @@ | ||
# syntax=docker/dockerfile:1@sha256:ac85f380a63b13dfcefa89046420e1781752bab202122f8f50032edf31be0021 | ||
|
||
FROM node:20.10.0-bookworm AS deps | ||
ARG NODE_ENV=production | ||
WORKDIR /app | ||
COPY ./package*.json ./ | ||
RUN npm ci | ||
|
||
FROM --platform=$BUILDPLATFORM node:20.10.0-bookworm AS builder | ||
ARG NODE_ENV=development | ||
WORKDIR /app | ||
COPY ./build.js ./ | ||
COPY ./package*.json ./ | ||
RUN npm ci | ||
COPY ./src/ ./src/ | ||
RUN npm run build | ||
|
||
FROM --platform=$BUILDPLATFORM node:20.10.0-bookworm AS model-fetch | ||
|
||
FROM buildpack-deps:bookworm AS model-fetch | ||
WORKDIR /app | ||
RUN wget https://github.com/jpreprocess/jpreprocess/releases/download/v0.6.1/naist-jdic-jpreprocess.tar.gz \ | ||
&& tar xzf naist-jdic-jpreprocess.tar.gz \ | ||
&& rm naist-jdic-jpreprocess.tar.gz | ||
RUN git clone --depth 1 https://github.com/icn-lab/htsvoice-tohoku-f01.git | ||
|
||
FROM gcr.io/distroless/nodejs20-debian12:nonroot@sha256:015be521134f97b5f2b4c1543615eb4be907fadc8c6a52e60fd0c18f7cda0337 AS runner | ||
FROM ghcr.io/jqlang/jq:1.7 as fetch-jq | ||
|
||
FROM quay.io/curl/curl-base:8.4.0 as fetch-pnpm | ||
ENV SHELL="sh" | ||
ENV ENV="/tmp/env" | ||
ENV PNPM_HOME="/pnpm" | ||
WORKDIR /dist | ||
RUN --mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,from=fetch-jq,source=/jq,target=/mounted-bin/jq \ | ||
curl -fsSL --compressed https://get.pnpm.io/install.sh | env PNPM_VERSION=$(cat package.json | /mounted-bin/jq -r .packageManager | grep -oE '[0-9]+\.[0-9]+\.[0-9]+') sh - | ||
|
||
FROM buildpack-deps:bookworm as fetch-deps | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
WORKDIR /package | ||
COPY --link --from=fetch-pnpm /pnpm/ /pnpm/ | ||
RUN pnpm config set store-dir /.pnpm-store | ||
COPY --link .npmrc ./ | ||
RUN --mount=type=cache,target=/.pnpm-store \ | ||
# package.json: for simple-git-hooks | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ | ||
pnpm fetch | ||
COPY --link package.json ./ | ||
|
||
FROM fetch-deps as dev-deps | ||
RUN --mount=type=cache,target=/.pnpm-store \ | ||
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ | ||
pnpm install --frozen-lockfile --offline | ||
|
||
FROM buildpack-deps:bookworm as builder | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
WORKDIR /app | ||
RUN --mount=type=bind,from=fetch-deps,source=/pnpm/,target=/pnpm/ \ | ||
--mount=type=bind,from=dev-deps,source=/package/node_modules/,target=node_modules/ \ | ||
--mount=type=bind,source=package.json,target=package.json \ | ||
--mount=type=bind,source=.npmrc,target=.npmrc \ | ||
--mount=type=bind,source=build.js,target=build.js \ | ||
--mount=type=bind,source=src/,target=src/ \ | ||
pnpm build | ||
|
||
FROM fetch-deps as prod-deps | ||
ARG NODE_ENV="production" | ||
RUN --mount=type=cache,target=/.pnpm-store \ | ||
--mount=type=bind,source=pnpm-lock.yaml,target=pnpm-lock.yaml \ | ||
pnpm install --frozen-lockfile --offline | ||
|
||
FROM gcr.io/distroless/cc-debian12:nonroot as runner | ||
ENV PNPM_HOME="/pnpm" | ||
ENV PATH="$PNPM_HOME:$PATH" | ||
ENV NODE_ENV="production" | ||
WORKDIR /app | ||
ENV NODE_ENV=production | ||
COPY ./package.json ./ | ||
COPY --from=builder /app/dist/ ./dist/ | ||
COPY --from=deps /app/node_modules/ ./node_modules/ | ||
COPY --from=model-fetch /app/ ./model/ | ||
CMD ["dist/main.js"] | ||
COPY --link --from=model-fetch /app/ ./model/ | ||
COPY --link --from=fetch-deps /pnpm/ /pnpm/ | ||
COPY --link --from=builder /app/dist/ ./dist/ | ||
COPY --from=prod-deps /package/node_modules/ ./node_modules/ | ||
COPY --link .npmrc package.json ./ | ||
ENTRYPOINT [ "pnpm", "--shell-emulator" ] | ||
CMD [ "start" ] |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
services: | ||
discordbot-om: | ||
image: discordbot-om | ||
container_name: discordbot-om | ||
build: . | ||
env_file: .env | ||
pull_policy: build |
Oops, something went wrong.