th: quieter yarn please

yarn cache logs make woodpecker webui lag. this is not ideal.
lolsob-rspec
kouhai dev 2023-07-05 23:56:06 -07:00
parent d0edb9444c
commit c436a17459
2 changed files with 76 additions and 38 deletions

View File

@ -3,3 +3,7 @@ enableGlobalCache: true
nodeLinker: node-modules nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.4.1.cjs yarnPath: .yarn/releases/yarn-3.4.1.cjs
logFilters:
- code: YN0013
level: ${YARN_NOISE_LOG_CODE_LEVEL:-info}

View File

@ -4,76 +4,100 @@ ARG NODE_IMAGE=node:18.16-bullseye-slim
ARG RUBY_IMAGE=ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim ARG RUBY_IMAGE=ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim
FROM ${RUBY_IMAGE} as ruby FROM ${RUBY_IMAGE} as ruby
# build-base
FROM ${NODE_IMAGE} as build-base FROM ${NODE_IMAGE} as build-base
COPY --link --from=ruby /opt/ruby /opt/ruby COPY --link --from=ruby /opt/ruby /opt/ruby
ENV DEBIAN_FRONTEND="noninteractive" \ ENV DEBIAN_FRONTEND="noninteractive" \
PATH="${PATH}:/opt/ruby/bin" \ PATH="${PATH}:/opt/ruby/bin"
NODE_OPTIONS=--openssl-legacy-provider
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
WORKDIR /opt/mastodon WORKDIR /opt/mastodon
# hadolint ignore=DL3008 # hadolint ignore=DL3008
RUN apt-get update && \ RUN --mount=type=cache,id=apt,target=/var/cache/apt,sharing=private \
apt-get install -y --no-install-recommends build-essential \ set -eux && \
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 \
build-essential \
ca-certificates \ ca-certificates \
git \ git \
libicu-dev \
libidn11-dev \
libpq-dev \
libjemalloc-dev \
zlib1g-dev \
libgdbm-dev \ libgdbm-dev \
libgmp-dev \ libgmp-dev \
libicu-dev \
libidn11-dev \
libjemalloc-dev \
libpq-dev \
libreadline8 \
libssl-dev \ libssl-dev \
libyaml-0-2 \ libyaml-0-2 \
ca-certificates \
libreadline8 \
python3 \ python3 \
shared-mime-info shared-mime-info \
zlib1g-dev
COPY --link .yarn/releases/ /opt/mastodon/.yarn/releases/ COPY --link .yarn/releases/ /opt/mastodon/.yarn/releases/
COPY --link Gemfile* package.json yarn.lock .yarnrc.yml /opt/mastodon/ COPY --link Gemfile* package.json yarn.lock .yarnrc.yml /opt/mastodon/
RUN \ ENV NODE_OPTIONS=--openssl-legacy-provider \
YARN_GLOBAL_FOLDER=/opt/yarn \
YARN_ENABLE_GLOBAL_CACHE=1
RUN --mount=type=cache,id=bundle,target=/opt/bundle/cache,sharing=private \
--mount=type=cache,id=yarn,target=/opt/yarn/cache,sharing=private \
set -eux && \
bundle config set cache_path /opt/bundle/cache && \
bundle config set silence_root_warning 'true' && \
bundle cache --no-install && \
bundle config set --local deployment 'true' && \ bundle config set --local deployment 'true' && \
bundle config set --local without 'development test' && \ bundle install --local -j"$(nproc)" && \
bundle config set silence_root_warning true && \ yarn install --immutable
bundle install -j"$(nproc)" && \
yarn install && \
yarn cache clean
# Precompile assets # Precompile assets
# TODO(kouhai): we're currently patching node_modules because of emoji-mart. # TODO(kouhai): we're currently patching node_modules because of emoji-mart.
# we should integrate our own fork instead. # we should integrate our own fork instead.
COPY --link . /opt/mastodon COPY --link . /opt/mastodon
# build
FROM build-base AS build FROM build-base AS build
ENV RAILS_ENV="production" \ ENV RAILS_ENV="production" \
NODE_ENV="production" NODE_ENV="production"
ENV NODE_OPTIONS=--openssl-legacy-provider \
YARN_GLOBAL_FOLDER=/opt/yarn \
YARN_ENABLE_GLOBAL_CACHE=1
ENV OTP_SECRET=precompile_placeholder \ ENV OTP_SECRET=precompile_placeholder \
SECRET_KEY_BASE=precompile_placeholder \ SECRET_KEY_BASE=precompile_placeholder \
RAKE_NO_YARN_INSTALL_HACK=1 RAKE_NO_YARN_INSTALL_HACK=1
RUN mv ./emoji_data/all.json ./node_modules/emoji-mart/data/all.json && yarn install && \
ENV BOOTSNAP_CACHE_DIR=/opt/mastodon/bootsnap
RUN --mount=type=cache,id=yarn,target=/opt/yarn/cache,sharing=private \
--mount=type=cache,id=webpacker,target=/opt/webpacker/cache,sharing=private \
set -eux && \
mkdir -p tmp/cache && \
ln -sf /opt/webpacker/cache tmp/cache/webpacker && \
mv ./emoji_data/all.json ./node_modules/emoji-mart/data/all.json && \
yarn install && \
bundle exec rails assets:precompile bundle exec rails assets:precompile
# final image
FROM ${NODE_IMAGE} FROM ${NODE_IMAGE} as output
# Use those args to specify your own version flags & suffixes # Use those args to specify your own version flags & suffixes
ARG SOURCE_TAG=""
ARG MASTODON_VERSION_FLAGS="" ARG MASTODON_VERSION_FLAGS=""
ARG MASTODON_VERSION_SUFFIX="" ARG MASTODON_VERSION_SUFFIX=""
ARG UID="991" ARG UID="991"
ARG GID="991" ARG GID="991"
COPY --link --from=ruby /opt/ruby /opt/ruby
SHELL ["/bin/bash", "-o", "pipefail", "-c"] SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV DEBIAN_FRONTEND="noninteractive" \ ENV DEBIAN_FRONTEND="noninteractive" \
@ -81,34 +105,39 @@ ENV DEBIAN_FRONTEND="noninteractive" \
# Ignoring these here since we don't want to pin any versions and the Debian image removes apt-get content after use # Ignoring these here since we don't want to pin any versions and the Debian image removes apt-get content after use
# hadolint ignore=DL3008,DL3009 # hadolint ignore=DL3008,DL3009
RUN apt-get update && \ RUN --mount=type=cache,id=apt,target=/var/cache/apt,sharing=private \
set -eux && \
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 && \
echo "Etc/UTC" > /etc/localtime && \ echo "Etc/UTC" > /etc/localtime && \
groupadd -g "${GID}" mastodon && \ groupadd -g "${GID}" mastodon && \
useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \ useradd -l -u "$UID" -g "${GID}" -m -d /opt/mastodon mastodon && \
apt-get -y --no-install-recommends install whois \ apt-get -y --no-install-recommends install \
wget \ ca-certificates \
procps \
libssl1.1 \
libpq5 \
imagemagick \
ffmpeg \ ffmpeg \
libjemalloc2 \ file \
imagemagick \
libicu67 \ libicu67 \
libidn11 \ libidn11 \
libyaml-0-2 \ libjemalloc2 \
file \ libpq5 \
ca-certificates \
tzdata \
libreadline8 \ libreadline8 \
tini && \ libssl1.1 \
ln -s /opt/mastodon /mastodon libyaml-0-2 \
procps \
tini \
tzdata \
wget \
whois \
&& ln -s /opt/mastodon /mastodon
# Note: no, cleaning here since Debian does this automatically # Note: no, cleaning here since Debian does this automatically
# See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem # See the file /etc/apt/apt.conf.d/docker-clean within the Docker image's filesystem
COPY --link --from=ruby /opt/ruby /opt/ruby
COPY --link --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon COPY --link --chown=mastodon:mastodon --from=build /opt/mastodon /opt/mastodon
ARG SOURCE_TAG=''
ENV RAILS_ENV="production" \ ENV RAILS_ENV="production" \
NODE_ENV="production" \ NODE_ENV="production" \
RAILS_SERVE_STATIC_FILES="true" \ RAILS_SERVE_STATIC_FILES="true" \
@ -117,6 +146,11 @@ ENV RAILS_ENV="production" \
MASTODON_VERSION_FLAGS="${MASTODON_VERSION_FLAGS}" \ MASTODON_VERSION_FLAGS="${MASTODON_VERSION_FLAGS}" \
MASTODON_VERSION_SUFFIX="${MASTODON_VERSION_SUFFIX}" MASTODON_VERSION_SUFFIX="${MASTODON_VERSION_SUFFIX}"
ENV BOOTSNAP_CACHE_DIR=/opt/mastodon/bootsnap
# override this at will
ENV BOOTSNAP_READONLY=1
# Set the run user # Set the run user
USER mastodon USER mastodon
WORKDIR /opt/mastodon WORKDIR /opt/mastodon