-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from v-ut-d/optimize-dockerfile
Optimize Dockerfile
- Loading branch information
Showing
5 changed files
with
90 additions
and
63 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,38 +1,51 @@ | ||
FROM node:16-bullseye-slim AS base | ||
RUN apt-get update -y&&apt-get install -y openssl\ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
# Please use `docker buildx build` instead of normal `docker build` to build this Dockerfile. | ||
# e.g. `docker buildx build --platform=linux/arm64,linux/amd64 .` | ||
|
||
|
||
FROM base AS builder | ||
FROM --platform=$BUILDPLATFORM node:16-bullseye-slim AS builder | ||
|
||
WORKDIR /app | ||
COPY ./package*.json ./tsconfig.json ./prisma/schema.prisma ./ | ||
|
||
RUN apt-get update -y&&apt-get install -y curl python3 \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./package*.json ./ | ||
RUN sed '/prepare/d' -i package.json | ||
|
||
RUN npm ci --ignore-scripts | ||
|
||
COPY ./tsconfig.json ./prisma/schema.prisma ./ | ||
COPY ./src ./src | ||
RUN npm run build | ||
|
||
FROM base AS runner | ||
|
||
WORKDIR /app | ||
ENV NODE_ENV production | ||
|
||
COPY --from=builder /app/dist ./dist | ||
COPY ./prisma ./prisma | ||
FROM builder AS modules | ||
ARG TARGETARCH | ||
RUN npm ci --target_arch=$(echo "$TARGETARCH"|sed s/amd64/x64/) | ||
|
||
|
||
|
||
FROM builder AS dict | ||
RUN npm --prefix node_modules/node-openjtalk-binding/ run install | ||
COPY ./script ./script | ||
COPY ./package*.json ./ | ||
RUN npm run compile-dict | ||
|
||
RUN sed '/prepare/d' -i package.json | ||
|
||
RUN apt-get update -y&&apt-get install -y python3 curl g++ make \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
RUN npm ci | ||
RUN apt-get remove -y python3 curl g++ make \ | ||
|
||
FROM node:16-bullseye-slim | ||
|
||
WORKDIR /app | ||
ENV NODE_ENV production | ||
|
||
RUN apt-get update -y&&apt-get install -y openssl \ | ||
&& apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY ./prisma ./prisma | ||
COPY ./package*.json ./ | ||
COPY --from=builder /app/dist ./dist | ||
COPY --from=dict /app/dictionary ./dictionary | ||
COPY --from=modules /app/node_modules ./node_modules | ||
|
||
CMD ["npm", "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
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,6 +1,6 @@ | ||
#!/bin/sh | ||
|
||
rm -r dictionary>/dev/null | ||
rm -r dictionary 2> /dev/null | ||
mkdir -p dictionary/tmp | ||
cd dictionary/tmp | ||
|
||
|