Skip to content

Commit

Permalink
Merge remote-tracking branch 'mastodon/main' into merge/mastodon-main…
Browse files Browse the repository at this point in the history
…-branch
  • Loading branch information
S-H-GAMELINKS committed Jun 17, 2024
2 parents 8766bbd + d5f02ad commit 6fea0a7
Show file tree
Hide file tree
Showing 168 changed files with 684 additions and 537 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:

- name: Run brakeman
if: always() # Run both checks, even if the first failed
run: bundle exec brakeman
run: bin/brakeman
2 changes: 1 addition & 1 deletion .github/workflows/rebase-needed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

steps:
- name: Check for merge conflicts
uses: eps1lon/actions-label-merge-conflict@releases/2.x
uses: eps1lon/actions-label-merge-conflict@v3
with:
dirtyLabel: 'rebase needed :construction:'
repoToken: '${{ secrets.GITHUB_TOKEN }}'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test-migrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ jobs:
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 6379:6379

Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ jobs:
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 6379:6379

Expand Down Expand Up @@ -166,19 +166,19 @@ jobs:
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 6379:6379

Expand Down Expand Up @@ -254,19 +254,19 @@ jobs:
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 6379:6379

Expand Down Expand Up @@ -344,19 +344,19 @@ jobs:
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
--health-interval 10ms
--health-timeout 3s
--health-retries 50
ports:
- 6379:6379

Expand Down
10 changes: 10 additions & 0 deletions .rubocop/rspec.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
---
RSpec/ExampleLength:
CountAsOne: ['array', 'heredoc', 'method_call']
Max: 20 # Override default of 5

RSpec/MultipleExpectations:
Max: 10 # Overrides default of 1

RSpec/MultipleMemoizedHelpers:
Max: 20 # Overrides default of 5

RSpec/NamedSubject:
EnforcedStyle: named_only

RSpec/NestedGroups:
Max: 10 # Overrides default of 3

RSpec/NotToNot:
EnforcedStyle: to_not

Expand Down
15 changes: 0 additions & 15 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ Metrics/CyclomaticComplexity:
Metrics/PerceivedComplexity:
Max: 27

# Configuration parameters: CountAsOne.
RSpec/ExampleLength:
Max: 18

RSpec/MultipleExpectations:
Max: 7

# Configuration parameters: AllowSubject.
RSpec/MultipleMemoizedHelpers:
Max: 17

# Configuration parameters: AllowedGroups.
RSpec/NestedGroups:
Max: 6

Rails/OutputSafety:
Exclude:
- 'config/initializers/simple_form.rb'
Expand Down
81 changes: 70 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ ENV \
# Apply Mastodon version information
MASTODON_VERSION_PRERELEASE="${MASTODON_VERSION_PRERELEASE}" \
MASTODON_VERSION_METADATA="${MASTODON_VERSION_METADATA}" \
# Enable libvips
MASTODON_USE_LIBVIPS=true \
# Apply Mastodon static files and YJIT options
RAILS_SERVE_STATIC_FILES=${RAILS_SERVE_STATIC_FILES} \
RUBY_YJIT_ENABLE=${RUBY_YJIT_ENABLE} \
Expand All @@ -67,7 +65,9 @@ ENV \
DEBIAN_FRONTEND="noninteractive" \
PATH="${PATH}:/opt/ruby/bin:/opt/mastodon/bin" \
# Optimize jemalloc 5.x performance
MALLOC_CONF="narenas:2,background_thread:true,thp:never,dirty_decay_ms:1000,muzzy_decay_ms:0"
MALLOC_CONF="narenas:2,background_thread:true,thp:never,dirty_decay_ms:1000,muzzy_decay_ms:0" \
# Enable libvips, should not be changed
MASTODON_USE_LIBVIPS=true

# Set default shell used for running commands
SHELL ["/bin/bash", "-o", "pipefail", "-o", "errexit", "-c"]
Expand Down Expand Up @@ -104,7 +104,6 @@ RUN \
curl \
ffmpeg \
file \
libvips42 \
libjemalloc2 \
patchelf \
procps \
Expand Down Expand Up @@ -138,18 +137,31 @@ RUN \
--mount=type=cache,id=apt-lib-${TARGETPLATFORM},target=/var/lib/apt,sharing=locked \
# Install build tools and bundler dependencies from APT
apt-get install -y --no-install-recommends \
g++ \
gcc \
build-essential \
git \
libgdbm-dev \
libglib2.0-dev \
libgmp-dev \
libicu-dev \
libidn-dev \
libpq-dev \
libssl-dev \
make \
meson \
pkg-config \
shared-mime-info \
zlib1g-dev \
# libvips components
libcgif-dev \
libexif-dev \
libexpat1-dev \
libgirepository1.0-dev \
libheif-dev \
libimagequant-dev \
libjpeg62-turbo-dev \
liblcms2-dev \
liborc-dev \
libspng-dev \
libtiff-dev \
libwebp-dev \
;

RUN \
Expand All @@ -158,6 +170,26 @@ RUN \
corepack enable; \
corepack prepare --activate;

# Create temporary libvips specific build layer from build layer
FROM build as libvips

# libvips version to compile, change with [--build-arg VIPS_VERSION="8.15.2"]
# renovate: datasource=github-releases depName=libvips packageName=libvips/libvips
ARG VIPS_VERSION=8.15.2
# libvips download URL, change with [--build-arg VIPS_URL="https://github.com/libvips/libvips/releases/download"]
ARG VIPS_URL=https://github.com/libvips/libvips/releases/download

WORKDIR /usr/local/libvips/src

RUN \
curl -sSL -o vips-${VIPS_VERSION}.tar.xz ${VIPS_URL}/v${VIPS_VERSION}/vips-${VIPS_VERSION}.tar.xz; \
tar xf vips-${VIPS_VERSION}.tar.xz; \
cd vips-${VIPS_VERSION}; \
meson setup build --prefix /usr/local/libvips --libdir=lib -Ddeprecated=false -Dintrospection=disabled -Dmodules=disabled -Dexamples=false; \
cd build; \
ninja; \
ninja install;

# Create temporary bundler specific build layer from build layer
FROM build as bundler

Expand Down Expand Up @@ -207,10 +239,14 @@ COPY . /opt/mastodon/
COPY --from=yarn /opt/mastodon /opt/mastodon/
COPY --from=bundler /opt/mastodon /opt/mastodon/
COPY --from=bundler /usr/local/bundle/ /usr/local/bundle/
# Copy libvips components to layer for precompiler
COPY --from=libvips /usr/local/libvips/bin /usr/local/bin
COPY --from=libvips /usr/local/libvips/lib /usr/local/lib

ARG TARGETPLATFORM

RUN \
ldconfig; \
# Use Ruby on Rails to create Mastodon assets
SECRET_KEY_BASE_DUMMY=1 \
bundle exec rails assets:precompile; \
Expand All @@ -232,12 +268,27 @@ RUN \
--mount=type=cache,id=yarn-cache-${TARGETPLATFORM},target=/usr/local/share/.cache/yarn,sharing=locked \
# Apt update install non-dev versions of necessary components
apt-get install -y --no-install-recommends \
libssl3 \
libpq5 \
libexpat1 \
libglib2.0-0 \
libicu72 \
libidn12 \
libpq5 \
libreadline8 \
libssl3 \
libyaml-0-2 \
# libvips components
libcgif0 \
libexif12 \
libheif1 \
libimagequant0 \
libjpeg62-turbo \
liblcms2-2 \
liborc-0.4-0 \
libspng0 \
libtiff6 \
libwebp7 \
libwebpdemux2 \
libwebpmux3 \
;

# Copy Mastodon sources into final layer
Expand All @@ -248,9 +299,17 @@ COPY --from=precompiler /opt/mastodon/public/packs /opt/mastodon/public/packs
COPY --from=precompiler /opt/mastodon/public/assets /opt/mastodon/public/assets
# Copy bundler components to layer
COPY --from=bundler /usr/local/bundle/ /usr/local/bundle/
# Copy libvips components to layer
COPY --from=libvips /usr/local/libvips/bin /usr/local/bin
COPY --from=libvips /usr/local/libvips/lib /usr/local/lib

RUN \
ldconfig; \
# Smoketest media processors
vips -v;

RUN \
# Precompile bootsnap code for faster Rails startup
# Precompile bootsnap code for faster Rails startup
bundle exec bootsnap precompile --gemfile app/ lib/;

RUN \
Expand Down
Loading

0 comments on commit 6fea0a7

Please sign in to comment.