diff --git a/mastodon/Dockerfile.master b/mastodon/Dockerfile.master new file mode 100644 index 0000000..83246bc --- /dev/null +++ b/mastodon/Dockerfile.master @@ -0,0 +1,72 @@ +FROM alpine:3.6 + +ARG VERSION=master +ARG REPOSITORY=tootsuite/mastodon + +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 + +RUN apk -U upgrade \ + && apk add \ + ca-certificates \ + ffmpeg \ + file \ + git \ + imagemagick \ + libpq \ + libressl \ + libxml2 \ + libxslt \ + nodejs-current-npm \ + nodejs-current \ + protobuf \ + ruby \ + ruby-bigdecimal \ + ruby-io-console \ + ruby-irb \ + ruby-json \ + s6 \ + su-exec \ + && apk add -t build-dependencies \ + build-base \ + libffi-dev \ + libxml2-dev \ + libxslt-dev \ + postgresql-dev \ + protobuf-dev \ + python \ + ruby-dev \ + ruby-rdoc \ + tar \ + && update-ca-certificates \ + && wget -qO- https://github.com/${REPOSITORY}/archive/${VERSION}.tar.gz | tar xz --strip 1 \ + && gem install bundler \ + && bundle install --deployment --clean --no-cache --without test development \ + && npm install -g npm@3 && npm install -g yarn \ + && yarn --ignore-optional --pure-lockfile \ + && SECRET_KEY_BASE=$(rake secret) rake assets:precompile \ + && npm -g cache clean && yarn cache clean \ + && mv public/assets /tmp/assets && mv public/packs /tmp/packs \ + && apk del build-dependencies \ + && rm -rf /tmp/* /var/cache/apk/* + +COPY rootfs / + +RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* + +VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs /mastodon/log + +EXPOSE 3000 4000 + +LABEL maintainer="Wonderfall " \ + description="A GNU Social-compatible microblogging server" + +ENTRYPOINT ["/usr/local/bin/run"] +CMD ["/bin/s6-svscan", "/etc/s6.d"] diff --git a/mastodon/Dockerfile.stable b/mastodon/Dockerfile.stable new file mode 100644 index 0000000..fa56ab2 --- /dev/null +++ b/mastodon/Dockerfile.stable @@ -0,0 +1,72 @@ +FROM alpine:3.6 + +ARG VERSION=v1.4.1 +ARG REPOSITORY=tootsuite/mastodon + +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 + +RUN apk -U upgrade \ + && apk add \ + ca-certificates \ + ffmpeg \ + file \ + git \ + imagemagick \ + libpq \ + libressl \ + libxml2 \ + libxslt \ + nodejs-current-npm \ + nodejs-current \ + protobuf \ + ruby \ + ruby-bigdecimal \ + ruby-io-console \ + ruby-irb \ + ruby-json \ + s6 \ + su-exec \ + && apk add -t build-dependencies \ + build-base \ + libffi-dev \ + libxml2-dev \ + libxslt-dev \ + postgresql-dev \ + protobuf-dev \ + python \ + ruby-dev \ + ruby-rdoc \ + tar \ + && update-ca-certificates \ + && wget -qO- https://github.com/${REPOSITORY}/archive/${VERSION}.tar.gz | tar xz --strip 1 \ + && gem install bundler \ + && bundle install --deployment --clean --no-cache --without test development \ + && npm install -g npm@3 && npm install -g yarn \ + && yarn --ignore-optional --pure-lockfile \ + && SECRET_KEY_BASE=$(rake secret) rake assets:precompile \ + && npm -g cache clean && yarn cache clean \ + && mv public/assets /tmp/assets && mv public/packs /tmp/packs \ + && apk del build-dependencies \ + && rm -rf /tmp/* /var/cache/apk/* + +COPY rootfs / + +RUN chmod +x /usr/local/bin/* /etc/s6.d/*/* /etc/s6.d/.s6-svscan/* + +VOLUME /mastodon/public/system /mastodon/public/assets /mastodon/public/packs /mastodon/log + +EXPOSE 3000 4000 + +LABEL maintainer="Wonderfall " \ + description="A GNU Social-compatible microblogging server" + +ENTRYPOINT ["/usr/local/bin/run"] +CMD ["/bin/s6-svscan", "/etc/s6.d"] diff --git a/mastodon/README.md b/mastodon/README.md new file mode 100644 index 0000000..c143aeb --- /dev/null +++ b/mastodon/README.md @@ -0,0 +1,62 @@ +## wonderfall/mastodon + +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 on more than one machine. + +#### Features +- Based on Alpine Linux 3.6. +- As lightweight as possible. +- All-in-one container (s6). +- Assets are precompiled. +- Database migrations can be run at startup. +- No root processes. + +#### Docker Hub tags +- **master** : latest code for adventurers +- **stable** : latest stable version + +#### Build-time variables +- **VERSION** : version of Mastodon, can be `v1.4.1` or `master`. *(default : master)* +- **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 +``` +