Skip to content

Commit

Permalink
Merge pull request #84 from linuxserver/yarn4
Browse files Browse the repository at this point in the history
Rebase to 3.19, switch to corepack for node builds
  • Loading branch information
thespad authored Dec 21, 2023
2 parents ac25603 + d047cfa commit ed6e24e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 49 deletions.
35 changes: 11 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.18
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:3.19

ARG BUILD_DATE
ARG VERSION
Expand All @@ -10,7 +10,6 @@ LABEL maintainer="thespad"

ENV RAILS_ENV="production" \
NODE_ENV="production" \
NODE_OPTIONS="--openssl-legacy-provider" \
PATH="${PATH}:/app/www/bin" \
S6_STAGE2_HOOK="/init-hook"

Expand All @@ -33,10 +32,10 @@ RUN \
libpq-dev \
libxml2-dev \
libxslt-dev \
npm \
openssl-dev \
ruby-dev \
yaml-dev \
yarn && \
yaml-dev && \
echo "**** install mastodon ****" && \
mkdir -p /app/www && \
if [ -z ${MASTODON_VERSION+x} ]; then \
Expand All @@ -50,19 +49,18 @@ RUN \
/tmp/mastodon.tar.gz -C \
/app/www/ --strip-components=1 && \
cd /app/www && \
# https://github.com/mastodon/mastodon/pull/24702
sed -En "s/.*\brequire\('([^']+)'\).*/\"\1\"/p" streaming/index.js > streaming-requires.txt && \
jq --slurpfile requires streaming-requires.txt \
'{ dependencies: .dependencies | with_entries(select([.key] | inside($requires))) }' \
package.json > streaming/package.json && \
bundle config set --local deployment 'true' && \
bundle config set --local without 'development test exclude' && \
bundle config set silence_root_warning true && \
bundle install -j"$(nproc)" --no-cache && \
yarn install --production --frozen-lockfile --check-files && \
cd streaming && \
yarn install --production --check-files && \
npm install -g corepack && \
corepack enable && \
yarn workspaces focus --production @mastodon/mastodon && \
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
bundle exec bootsnap precompile --gemfile app/ lib/ && \
rm -rf /app/www/node_modules && \
cd streaming && \
yarn workspaces focus --production @mastodon/streaming && \
echo "**** cleanup ****" && \
yarn cache clean && \
apk del --purge \
Expand Down Expand Up @@ -98,18 +96,7 @@ RUN \
-o -name '*LICENSE*' \
-o -name 'Rakefile' \
-o -name '.*' \) \
-type f -delete && \
# Remove source maps, TS files, docs, tests and other useless files.
find /app/www/streaming/node_modules \( -name '.*' \
-o -name '*.map' \
-o -name '*.md' \
-o -name '*.ts' \
-o -name 'LICENSE*' \
-o -name 'Makefile' \
-o -name 'README*' \) \
-type f -delete && \
rm -rf /app/www/streaming/node_modules/*/test && \
rm -rf /app/www/node_modules
-type f -delete

COPY root/ /

Expand Down
35 changes: 11 additions & 24 deletions Dockerfile.aarch64
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1

FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.18
FROM ghcr.io/linuxserver/baseimage-alpine-nginx:arm64v8-3.19

ARG BUILD_DATE
ARG VERSION
Expand All @@ -10,7 +10,6 @@ LABEL maintainer="thespad"

ENV RAILS_ENV="production" \
NODE_ENV="production" \
NODE_OPTIONS="--openssl-legacy-provider" \
PATH="${PATH}:/app/www/bin" \
S6_STAGE2_HOOK="/init-hook"

Expand All @@ -34,11 +33,11 @@ RUN \
libpq-dev \
libxml2-dev \
libxslt-dev \
npm \
openssl-dev \
python3-dev \
ruby-dev \
yaml-dev \
yarn && \
yaml-dev && \
echo "**** install mastodon ****" && \
mkdir -p /app/www && \
if [ -z ${MASTODON_VERSION+x} ]; then \
Expand All @@ -52,20 +51,19 @@ RUN \
/tmp/mastodon.tar.gz -C \
/app/www/ --strip-components=1 && \
cd /app/www && \
# https://github.com/mastodon/mastodon/pull/24702
sed -En "s/.*\brequire\('([^']+)'\).*/\"\1\"/p" streaming/index.js > streaming-requires.txt && \
jq --slurpfile requires streaming-requires.txt \
'{ dependencies: .dependencies | with_entries(select([.key] | inside($requires))) }' \
package.json > streaming/package.json && \
bundle config set --local deployment 'true' && \
bundle config set --local without 'development test exclude' && \
bundle config set silence_root_warning true && \
bundle config set force_ruby_platform true && \
bundle install -j"$(nproc)" --no-cache && \
yarn install --production --frozen-lockfile --check-files && \
cd streaming && \
yarn install --production --check-files && \
npm install -g corepack && \
corepack enable && \
yarn workspaces focus --production @mastodon/mastodon && \
OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile && \
bundle exec bootsnap precompile --gemfile app/ lib/ && \
rm -rf /app/www/node_modules && \
cd streaming && \
yarn workspaces focus --production @mastodon/streaming && \
echo "**** cleanup ****" && \
yarn cache clean && \
apk del --purge \
Expand Down Expand Up @@ -101,18 +99,7 @@ RUN \
-o -name '*LICENSE*' \
-o -name 'Rakefile' \
-o -name '.*' \) \
-type f -delete && \
# Remove source maps, TS files, docs, tests and other useless files.
find /app/www/streaming/node_modules \( -name '.*' \
-o -name '*.map' \
-o -name '*.md' \
-o -name '*.ts' \
-o -name 'LICENSE*' \
-o -name 'Makefile' \
-o -name 'README*' \) \
-type f -delete && \
rm -rf /app/www/streaming/node_modules/*/test && \
rm -rf /app/www/node_modules
-type f -delete

COPY root/ /

Expand Down
3 changes: 2 additions & 1 deletion root/etc/s6-overlay/s6-rc.d/svc-streaming/run
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
# shellcheck shell=bash

export NODE_ENV=production
export HOME=/config
export PATH="${PATH}:/app/www/bin"

exec \
s6-notifyoncheck -d -n 300 -w 1000 -c "nc -z localhost 4000" \
cd /app/www s6-setuidgid abc node ./streaming
cd /app/www s6-setuidgid abc yarn workspace @mastodon/streaming start

0 comments on commit ed6e24e

Please sign in to comment.