Improve Dockerfile (#9105)

* Improve Dockerfile

* Update base image

* Add copy layer

* Delete unused RUN

* Update Dockerfile

Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>

Co-authored-by: Acid Chicken (硫酸鶏) <root@acid-chicken.com>
This commit is contained in:
Takuya Yoshida 2022-12-22 14:30:35 +09:00 committed by GitHub
parent 69087f2242
commit 9314ceae36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,23 +2,35 @@ FROM node:18.12.1-bullseye AS builder
ARG NODE_ENV=production ARG NODE_ENV=production
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
build-essential
WORKDIR /misskey WORKDIR /misskey
COPY [".yarnrc.yml", "package.json", "yarn.lock", "./"]
COPY [".yarn", "./.yarn"]
COPY ["scripts", "./scripts"]
COPY ["packages/backend/package.json", "./packages/backend/"]
COPY ["packages/client/package.json", "./packages/client/"]
COPY ["packages/sw/package.json", "./packages/sw/"]
RUN yarn install --immutable
COPY . ./ COPY . ./
RUN apt-get update
RUN apt-get install -y build-essential
RUN git submodule update --init RUN git submodule update --init
RUN yarn install --immutable
RUN yarn build RUN yarn build
RUN rm -rf .git
FROM node:18.12.1-bullseye-slim AS runner FROM node:18.12.1-bullseye-slim AS runner
WORKDIR /misskey WORKDIR /misskey
RUN apt-get update RUN apt-get update \
RUN apt-get install -y ffmpeg tini && apt-get install -y --no-install-recommends \
ffmpeg tini \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/*
COPY --from=builder /misskey/.yarn/install-state.gz ./.yarn/install-state.gz COPY --from=builder /misskey/.yarn/install-state.gz ./.yarn/install-state.gz
COPY --from=builder /misskey/node_modules ./node_modules COPY --from=builder /misskey/node_modules ./node_modules