File size: 2,088 Bytes
9141ebf
 
5787436
9141ebf
 
 
e07426b
5787436
9141ebf
 
e07426b
 
 
 
6ed8732
9141ebf
 
 
 
 
6ed8732
 
9141ebf
b9dbd15
6ed8732
b9dbd15
 
 
9141ebf
b80de2e
 
 
91d83c3
 
 
9141ebf
 
 
6ed8732
9141ebf
 
6ed8732
9141ebf
91d83c3
9141ebf
91d83c3
5787436
9141ebf
91d83c3
 
 
9141ebf
 
 
 
 
 
 
 
 
 
 
981ef9d
ae548ce
9141ebf
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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"]