FROM ubuntu:22.04 # Install system dependencies, including libffi-dev, libyaml-dev, and libidn11-dev RUN apt-get update && apt-get install -y \ curl git build-essential libssl-dev libreadline-dev zlib1g-dev \ sqlite3 libsqlite3-dev imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev \ ruby ruby-dev python3 python3-pip \ libffi-dev libyaml-dev libidn11-dev && \ apt-get clean # Install Node.js 18.x from NodeSource (includes npm) RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash - && \ apt-get install -y nodejs # Install rbenv and Ruby 3.3.5 (matches Mastodon v4.3.0 requirement) RUN git clone https://github.com/rbenv/rbenv.git /root/.rbenv && \ git clone https://github.com/rbenv/ruby-build.git /root/.rbenv/plugins/ruby-build && \ echo 'export PATH="/root/.rbenv/bin:$PATH"' >> /root/.bashrc && \ echo 'eval "$(rbenv init -)"' >> /root/.bashrc ENV PATH="/root/.rbenv/bin:/root/.rbenv/shims:$PATH" RUN rbenv install 3.3.5 && \ rbenv global 3.3.5 # Install Bundler and enable Corepack for Yarn 4.5.0 RUN gem install bundler -v 2.5.6 && \ npm install -g corepack && \ corepack enable && \ corepack prepare yarn@4.5.0 --activate # Create /app directory and set up non-root user RUN mkdir /app && \ useradd -m -s /bin/bash mastodon && \ chown -R mastodon:mastodon /app USER mastodon # Set working directory WORKDIR /app # Clone Mastodon and lock to v4.3.0 RUN git clone https://github.com/mastodon/mastodon.git mastodon && \ cd mastodon && \ git checkout v4.3.0 # Install Mastodon dependencies (include development group for annotate) WORKDIR /app/mastodon RUN bundle install && \ yarn install # Switch back to root for file copying and final steps USER root # Copy app files COPY app.py /app/ COPY mastodon_config.py /app/mastodon/ # Install Python dependencies COPY requirements.txt /app/ RUN pip3 install -r /app/requirements.txt # Precompile assets RUN RAILS_ENV=development bundle exec rake assets:precompile # Expose port 7860 EXPOSE 7860 # Run the app CMD ["python3", "/app/app.py"]