add files
This commit is contained in:
commit
a8e943364b
7 changed files with 208 additions and 0 deletions
85
Dockerfile
Normal file
85
Dockerfile
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
FROM ruby:2.4.4-alpine3.7
|
||||||
|
|
||||||
|
ARG VERSION=v2.4.1
|
||||||
|
ARG REPOSITORY=tootsuite/mastodon
|
||||||
|
ARG LIBICONV_VERSION=1.15
|
||||||
|
|
||||||
|
ENV UID=991 GID=991 \
|
||||||
|
RUN_DB_MIGRATIONS=true \
|
||||||
|
SIDEKIQ_WORKERS=5 \
|
||||||
|
RAILS_SERVE_STATIC_FILES=true \
|
||||||
|
RAILS_ENV=production \
|
||||||
|
NODE_ENV=production \
|
||||||
|
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mastodon/bin
|
||||||
|
|
||||||
|
WORKDIR /mastodon
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
RUN apk -U upgrade \
|
||||||
|
&& apk add \
|
||||||
|
ca-certificates \
|
||||||
|
ffmpeg \
|
||||||
|
file \
|
||||||
|
git \
|
||||||
|
icu-libs \
|
||||||
|
imagemagick \
|
||||||
|
libidn \
|
||||||
|
libpq \
|
||||||
|
libressl \
|
||||||
|
nodejs-npm \
|
||||||
|
nodejs \
|
||||||
|
protobuf \
|
||||||
|
s6 \
|
||||||
|
su-exec \
|
||||||
|
tzdata \
|
||||||
|
|
||||||
|
# Install build dependencies
|
||||||
|
&& apk add -t build-dependencies \
|
||||||
|
build-base \
|
||||||
|
icu-dev \
|
||||||
|
libidn-dev \
|
||||||
|
libtool \
|
||||||
|
postgresql-dev \
|
||||||
|
protobuf-dev \
|
||||||
|
python \
|
||||||
|
tar \
|
||||||
|
yarn \
|
||||||
|
|
||||||
|
# Update CA certificates
|
||||||
|
&& update-ca-certificates \
|
||||||
|
|
||||||
|
# Install GNU Libiconv
|
||||||
|
&& wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${LIBICONV_VERSION}.tar.gz -O /tmp/libiconv-${LIBICONV_VERSION}.tar.gz \
|
||||||
|
&& mkdir /tmp/src && tar xzf /tmp/libiconv-${LIBICONV_VERSION}.tar.gz -C /tmp/src \
|
||||||
|
&& cd /tmp/src/libiconv-${LIBICONV_VERSION} \
|
||||||
|
&& ./configure --prefix=/usr/local \
|
||||||
|
&& make -j$(getconf _NPROCESSORS_ONLN) && make install && libtool --finish /usr/local/lib \
|
||||||
|
|
||||||
|
# Install Mastodon
|
||||||
|
&& cd /mastodon \
|
||||||
|
&& wget -qO- https://github.com/${REPOSITORY}/archive/${VERSION}.tar.gz | tar xz --strip 1 \
|
||||||
|
&& bundle config build.nokogiri --with-iconv-lib=/usr/local/lib --with-iconv-include=/usr/local/include \
|
||||||
|
&& bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --clean --no-cache --without test development \
|
||||||
|
&& yarn --ignore-optional --pure-lockfile \
|
||||||
|
|
||||||
|
# Precompile Mastodon assets
|
||||||
|
&& SECRET_KEY_BASE=$(bundle exec rake secret) OTP_SECRET=$(bundle exec rake secret) SMTP_FROM_ADDRESS= bundle exec rake assets:precompile \
|
||||||
|
|
||||||
|
# Clean
|
||||||
|
&& npm -g --force cache clean && yarn cache clean \
|
||||||
|
&& apk del build-dependencies \
|
||||||
|
&& rm -rf /var/cache/apk/* /tmp/src
|
||||||
|
|
||||||
|
COPY rootfs /
|
||||||
|
|
||||||
|
RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/*
|
||||||
|
|
||||||
|
VOLUME /mastodon/public/system /mastodon/log
|
||||||
|
|
||||||
|
EXPOSE 3000 4000
|
||||||
|
|
||||||
|
LABEL maintainer="Wonderfall <wonderfall@targaryen.house>" \
|
||||||
|
description="Your self-hosted, globally interconnected microblogging community"
|
||||||
|
|
||||||
|
ENTRYPOINT ["/usr/local/bin/run"]
|
||||||
|
CMD ["/bin/s6-svscan", "/etc/s6.d"]
|
60
README.md
Normal file
60
README.md
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
## wonderfall/mastodon
|
||||||
|
|
||||||
|
![Mastodon](https://github.com/tootsuite/mastodon/blob/master/app/javascript/images/mastodon-getting-started.png?raw=true)
|
||||||
|
|
||||||
|
A GNU Social-compatible microblogging server : https://github.com/tootsuite/mastodon
|
||||||
|
|
||||||
|
#### Why this image?
|
||||||
|
This image is not the official one. The main difference you can notice is that all processes (web, streaming, sidekiq) are running in a single container, thanks to s6 (a supervision suite). Therefore it's easier to deploy, but not recommended for scaling.
|
||||||
|
|
||||||
|
#### Features
|
||||||
|
- Based on Alpine Linux.
|
||||||
|
- As lightweight as possible.
|
||||||
|
- All-in-one container (s6).
|
||||||
|
- Assets are precompiled.
|
||||||
|
- Database migrations can be run at startup.
|
||||||
|
- No root processes.
|
||||||
|
|
||||||
|
#### Build-time variables
|
||||||
|
- **VERSION** : version of Mastodon, can be `v1.4.1` or `master`. *(default : latest version)*
|
||||||
|
- **REPOSITORY** : location of the code *(default : tootsuite/mastodon)*
|
||||||
|
|
||||||
|
#### Environment variables you should change
|
||||||
|
- **UID** : mastodon user id *(default : 991)*
|
||||||
|
- **GID** : mastodon group id *(default : 991)*
|
||||||
|
- **RUN_DB_MIGRATIONS** : run `rake db:migrate` at startup *(default : true)*
|
||||||
|
- **SIDEKIQ_WORKERS** : number of Sidekiq workers *(default : 5)*
|
||||||
|
- Other environment variables : https://github.com/tootsuite/mastodon/blob/master/.env.production.sample
|
||||||
|
|
||||||
|
#### Volumes
|
||||||
|
- **/mastodon/public/system** : shit like media attachments, avatars, etc.
|
||||||
|
- **/mastodon/public/assets** : Mastodon assets
|
||||||
|
- **/mastodon/public/packs** : Mastodon assets
|
||||||
|
- **/mastodon/log** : Mastodon logfiles (mount if you prefer to)
|
||||||
|
|
||||||
|
#### Ports
|
||||||
|
- **3000** : Mastodon web
|
||||||
|
- **4000** : Mastodon streaming
|
||||||
|
|
||||||
|
#### docker-compose sample
|
||||||
|
|
||||||
|
```
|
||||||
|
mastodon:
|
||||||
|
image: wonderfall/mastodon:stable
|
||||||
|
restart: always
|
||||||
|
container_name: mastodon
|
||||||
|
env_file: /home/docker/mastodon/.env.production
|
||||||
|
environment:
|
||||||
|
- WEB_CONCURRENCY=16
|
||||||
|
- MAX_THREADS=20
|
||||||
|
- SIDEKIQ_WORKERS=25
|
||||||
|
- RUN_DB_MIGRATIONS=true
|
||||||
|
links:
|
||||||
|
- mastodon-pgb
|
||||||
|
- mastodon-redis
|
||||||
|
volumes:
|
||||||
|
- /home/docker/mastodon/public/system:/mastodon/public/system
|
||||||
|
- /home/docker/mastodon/public/assets:/mastodon/public/assets
|
||||||
|
- /home/docker/mastodon/public/packs:/mastodon/public/packs
|
||||||
|
```
|
||||||
|
|
2
rootfs/etc/s6.d/.s6-svscan/finish
Normal file
2
rootfs/etc/s6.d/.s6-svscan/finish
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/sh
|
||||||
|
exit 0
|
3
rootfs/etc/s6.d/sidekiq/run
Normal file
3
rootfs/etc/s6.d/sidekiq/run
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd /mastodon
|
||||||
|
exec bundle exec sidekiq -c $SIDEKIQ_WORKERS -q default -q push -q pull -q mailers > ./log/sidekiq.log 2>&1
|
3
rootfs/etc/s6.d/streaming/run
Normal file
3
rootfs/etc/s6.d/streaming/run
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd /mastodon
|
||||||
|
exec npm run start > ./log/streaming.log 2>&1
|
3
rootfs/etc/s6.d/web/run
Normal file
3
rootfs/etc/s6.d/web/run
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
cd /mastodon
|
||||||
|
exec bundle exec puma -C config/puma.rb > ./log/web.log 2>&1
|
52
rootfs/usr/local/bin/run
Normal file
52
rootfs/usr/local/bin/run
Normal file
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
### 1. Adds local user (UID and GID are provided from environment variables).
|
||||||
|
### 2. Moves precompiled assets into them.
|
||||||
|
### 3. Updates permissions, except for ./public/system (should be chown on previous installations).
|
||||||
|
### NOTE : this can take a long time if overlay2 is the storage-driver (issue #3194).
|
||||||
|
### 4. If $RUN_DB_MIGRATIONS is set to true, runs the database migrations task.
|
||||||
|
### 5. Executes the command as that user.
|
||||||
|
|
||||||
|
echo "
|
||||||
|
---------------------------------------------
|
||||||
|
_____ _ _
|
||||||
|
| |___ ___| |_ ___ _| |___ ___
|
||||||
|
| | | | .'|_ -| _| . | . | . | |
|
||||||
|
|_|_|_|__,|___|_| |___|___|___|_|_|
|
||||||
|
|
||||||
|
A GNU Social-compatible microblogging server
|
||||||
|
https://github.com/tootsuite/mastodon
|
||||||
|
17j2g7vpgHhLuXhN4bueZFCvdxxieyRVWd
|
||||||
|
---------------------------------------------
|
||||||
|
UID/GID settings
|
||||||
|
---------------------------------------------
|
||||||
|
User ID : ${UID}
|
||||||
|
Group ID : ${GID}
|
||||||
|
---------------------------------------------
|
||||||
|
Logs location
|
||||||
|
---------------------------------------------
|
||||||
|
Sidekiq : /mastodon/log/sidekiq.log
|
||||||
|
Streaming : /mastodon/log/streaming.log
|
||||||
|
Web : /mastodon/log/web.log
|
||||||
|
---------------------------------------------
|
||||||
|
"
|
||||||
|
|
||||||
|
echo "Creating mastodon user..."
|
||||||
|
addgroup -g ${GID} mastodon &>/dev/null
|
||||||
|
adduser -h /mastodon -s /bin/sh -D -G mastodon -u ${UID} mastodon &>/dev/null
|
||||||
|
|
||||||
|
echo "Updating permissions, this can take a while..."
|
||||||
|
find /mastodon -path /mastodon/public/system -prune -o -not -user mastodon -not -group mastodon -print0 | xargs -0 chown -f mastodon:mastodon
|
||||||
|
chown -R mastodon:mastodon /etc/s6.d
|
||||||
|
|
||||||
|
if [ "$RUN_DB_MIGRATIONS" == "true" ]; then
|
||||||
|
echo "Running database migrations task..."
|
||||||
|
su-exec mastodon:mastodon bundle exec rake db:migrate
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Executing process(es)..."
|
||||||
|
if [ '$@' == '' ]; then
|
||||||
|
exec su-exec mastodon:mastodon /bin/s6-svscan /etc/s6.d
|
||||||
|
else
|
||||||
|
exec su-exec mastodon:mastodon "$@"
|
||||||
|
fi
|
Loading…
Reference in a new issue