Use cache on build (#9639)

This commit is contained in:
Takuya Yoshida 2023-01-27 11:30:22 +09:00 committed by GitHub
parent 7d9d1ae7c2
commit 7af0e38dd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -31,3 +31,5 @@ jobs:
push: true
tags: misskey/misskey:develop
labels: develop
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -2,8 +2,12 @@ ARG NODE_VERSION=18.13.0-bullseye
FROM node:${NODE_VERSION} AS builder
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
&& apt-get update \
&& apt-get install -yqq --no-install-recommends \
build-essential
RUN corepack enable
@ -16,7 +20,8 @@ COPY ["packages/backend/package.json", "./packages/backend/"]
COPY ["packages/frontend/package.json", "./packages/frontend/"]
COPY ["packages/sw/package.json", "./packages/sw/"]
RUN pnpm i --frozen-lockfile
RUN --mount=type=cache,target=/root/.local/share/pnpm/store,sharing=locked \
pnpm i --frozen-lockfile --aggregate-output
COPY . ./
@ -30,11 +35,13 @@ FROM node:${NODE_VERSION}-slim AS runner
ARG UID="991"
ARG GID="991"
RUN apt-get update \
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
--mount=type=cache,target=/var/lib/apt,sharing=locked \
rm -f /etc/apt/apt.conf.d/docker-clean \
; echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ffmpeg tini \
&& apt-get -y clean \
&& rm -rf /var/lib/apt/lists/* \
&& corepack enable \
&& groupadd -g "${GID}" misskey \
&& useradd -l -u "${UID}" -g "${GID}" -m -d /misskey misskey