FROM debian:bookworm-slim ENV DEBIAN_FRONTEND=noninteractive SHELL ["/bin/bash", "-c"] # --------------------------------------------------------------------------- # 1. Dépendances système # --------------------------------------------------------------------------- RUN apt-get update && apt-get install -y --no-install-recommends \ curl wget gnupg2 ca-certificates lsb-release software-properties-common \ apt-transport-https git-core build-essential libssl-dev libreadline-dev \ zlib1g-dev libpq-dev libicu-dev libidn11-dev libyaml-dev libjemalloc-dev \ imagemagick ffmpeg libvips-tools pkg-config \ postgresql-15 postgresql-client-15 postgresql-contrib-15 \ redis-server nginx supervisor \ autoconf bison patch rustc libffi-dev libgdbm-dev libncurses5-dev \ libsqlite3-dev sqlite3 \ && curl -fsSL https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install -y nodejs \ && apt-get clean && rm -rf /var/lib/apt/lists/* # --------------------------------------------------------------------------- # 2. Ruby 3.3.5 via rbenv # --------------------------------------------------------------------------- RUN git clone --depth 1 https://github.com/rbenv/rbenv.git /usr/local/rbenv \ && git clone --depth 1 https://github.com/rbenv/ruby-build.git /usr/local/rbenv/plugins/ruby-build \ && /usr/local/rbenv/plugins/ruby-build/install.sh \ && echo 'export RBENV_ROOT=/usr/local/rbenv' >> /etc/profile.d/rbenv.sh \ && echo 'export PATH=$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH' >> /etc/profile.d/rbenv.sh ENV RBENV_ROOT=/usr/local/rbenv ENV PATH=$RBENV_ROOT/bin:$RBENV_ROOT/shims:$PATH RUN rbenv init - bash >> /etc/bash.bashrc \ && rbenv install 3.3.5 \ && rbenv global 3.3.5 \ && gem install bundler --no-document # --------------------------------------------------------------------------- # 3. Corepack (Yarn 4) — EN ROOT # --------------------------------------------------------------------------- RUN corepack enable # --------------------------------------------------------------------------- # 4. Utilisateur & code Mastodon # --------------------------------------------------------------------------- RUN useradd -m -u 991 -s /bin/bash mastodon WORKDIR /opt/mastodon RUN git clone --depth 1 --branch v4.3.6 https://github.com/mastodon/mastodon.git . \ && chown -R mastodon:mastodon /opt/mastodon USER mastodon RUN bundle config deployment 'true' \ && bundle config without 'development test' \ && bundle install -j$(nproc) \ && yarn install USER root # --------------------------------------------------------------------------- # 5. Configuration Redis (daemonize no + dir /data/redis) & PostgreSQL run dir # --------------------------------------------------------------------------- RUN sed -i 's|^daemonize .*|daemonize no|' /etc/redis/redis.conf \ && sed -i 's|^dir .*|dir /data/redis|' /etc/redis/redis.conf \ && sed -i 's|^supervised .*|supervised no|' /etc/redis/redis.conf \ && sed -i 's|^bind .*|bind 127.0.0.1|' /etc/redis/redis.conf \ && mkdir -p /var/run/postgresql && chown postgres:postgres /var/run/postgresql # --------------------------------------------------------------------------- # 6. Nginx — supprime config par defaut sur port 80 # --------------------------------------------------------------------------- RUN rm -f /etc/nginx/sites-enabled/default COPY nginx.conf /etc/nginx/conf.d/mastodon.conf # --------------------------------------------------------------------------- # 7. Supervisor & init # --------------------------------------------------------------------------- COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf COPY init.sh /usr/local/bin/init.sh RUN chmod +x /usr/local/bin/init.sh # --------------------------------------------------------------------------- # 8. Répertoires de données persistants # --------------------------------------------------------------------------- RUN mkdir -p /data/postgresql /data/redis /data/mastodon/public/system /data/mastodon/tmp \ && chown -R mastodon:mastodon /data/mastodon \ && chown -R postgres:postgres /data/postgresql \ && chown -R redis:redis /data/redis EXPOSE 7860 CMD ["/usr/local/bin/init.sh"]