Compare commits

..

1 Commits

Author SHA1 Message Date
sn0w
3ba7df64b4 add basic healthcheck support 2019-09-05 12:35:53 +00:00
8 changed files with 46 additions and 83 deletions

View File

@ -1,3 +1,2 @@
data/ data/
cache/ cache/
emoji/

View File

@ -1,5 +1,5 @@
# Pleroma tag, commit, or branch to build # Pleroma tag, commit, or branch to build
PLEROMA_VERSION=stable PLEROMA_VERSION=master
# The directory where the containers store their stuff # The directory where the containers store their stuff
# Can be an absolute or relative path # Can be an absolute or relative path
@ -24,4 +24,3 @@ DOCKER_GID=1000
# or if you do not trust the admins of pleroma's Gitlab instance. # or if you do not trust the admins of pleroma's Gitlab instance.
# #
PLEROMA_GIT_REPO=https://git.pleroma.social/pleroma/pleroma.git PLEROMA_GIT_REPO=https://git.pleroma.social/pleroma/pleroma.git
# or, for example, https://git.ihatebeinga.live/IHBAGang/akkoma.git

1
.gitignore vendored
View File

@ -1,6 +1,5 @@
data/ data/
cache/ cache/
emoji/
custom.d/ custom.d/
!custom.d/.gitkeep !custom.d/.gitkeep
config.exs config.exs

View File

@ -1,4 +1,4 @@
FROM alpine:3.16 FROM alpine:3.10
ARG __VIA_SCRIPT ARG __VIA_SCRIPT
RUN \ RUN \
@ -25,11 +25,12 @@ RUN \
git curl rsync postgresql-client \ git curl rsync postgresql-client \
&& \ && \
apk add --no-cache --virtual .sdk \ apk add --no-cache --virtual .sdk \
build-base cmake file-dev \ build-base \
&& \ && \
apk add --no-cache --virtual .runtime \ apk add --no-cache --virtual .runtime \
imagemagick ffmpeg exiftool \ imagemagick \
elixir erlang erlang-dev elixir erlang erlang-runtime-tools \
erlang-xmerl erlang-ssl erlang-ssh erlang-eldap erlang-mnesia
# Add entrypoint # Add entrypoint
COPY ./entrypoint.sh / COPY ./entrypoint.sh /
@ -50,17 +51,10 @@ USER pleroma
WORKDIR /home/pleroma WORKDIR /home/pleroma
# Get pleroma sources # Get pleroma sources
#
# Also make sure that instance/static/emoji exists.
# Pleroma does not ship with an `instance` folder by default, causing docker to create `instance/static` for us at launch.
# In itself that wouldn't be much of an issue, but said folder(s) are created as root:pleroma with 2755.
# This breaks the custom.d step in entrypoint.sh which relies on writing there (See #10).
#
ARG PLEROMA_GIT_REPO ARG PLEROMA_GIT_REPO
RUN \ RUN \
echo "#> Getting pleroma sources from $PLEROMA_GIT_REPO..." 1>&2 && \ echo "#> Getting pleroma sources from $PLEROMA_GIT_REPO..." 1>&2 && \
git clone --progress $PLEROMA_GIT_REPO ./pleroma && \ git clone --progress $PLEROMA_GIT_REPO ./pleroma
mkdir -p ./pleroma/instance/static/emoji
WORKDIR /home/pleroma/pleroma WORKDIR /home/pleroma/pleroma

View File

@ -1,6 +1,6 @@
# Pleroma-Docker (Unofficial) # Pleroma-Docker (Unofficial)
[Pleroma](https://pleroma.social/) is a selfhosted social network that uses ActivityPub. [Pleroma](https://pleroma.social/) is a selfhosted social network that uses OStatus/ActivityPub.
This repository dockerizes it for easier deployment. This repository dockerizes it for easier deployment.
@ -17,7 +17,8 @@ This repository dockerizes it for easier deployment.
* thermonuclear war, or you getting fired because your boss saw your NSFW posts. * thermonuclear war, or you getting fired because your boss saw your NSFW posts.
* *
* Please do some research if you have any concerns about the * Please do some research if you have any concerns about the
* included features or software *before* using it. * included features or software ***before*** using it.
*
*/ */
``` ```
@ -25,15 +26,10 @@ This repository dockerizes it for easier deployment.
## In the Wild ## In the Wild
`cofe.rocks` is always managed by this script.<br/> My own instance is managed by this script.<br>
Take a look at [hosted/pleroma](/hosted/pleroma) if you get stuck or need some inspiration. Take a look at [hosted/pleroma](https://glitch.sh/hosted/pleroma) if you get stuck or need some inspiration.
Additionally it's known to run on (in no particular order): Does your instance use pleroma-docker?<br>
- social.interhop.org
- social.technodruide.ca
- is.badat.dev
Does your instance use pleroma-docker?<br/>
Let me know and I'll add you to this list. Let me know and I'll add you to this list.
## Docs ## Docs
@ -41,7 +37,7 @@ Let me know and I'll add you to this list.
These docs assume that you have at least a basic understanding These docs assume that you have at least a basic understanding
of the pleroma installation process and common docker commands. of the pleroma installation process and common docker commands.
If you have questions about Pleroma head over to https://docs.pleroma.social/. If you have questions about Pleroma head over to https://docs.pleroma.social/.<br>
For help with docker check out https://docs.docker.com/. For help with docker check out https://docs.docker.com/.
For other problems related to this script, contact me or open an issue :) For other problems related to this script, contact me or open an issue :)
@ -62,74 +58,61 @@ For other problems related to this script, contact me or open an issue :)
- [Configure a reverse-proxy](#my-instance-is-up-how-do-i-reach-it) - [Configure a reverse-proxy](#my-instance-is-up-how-do-i-reach-it)
- Profit! - Profit!
Hint: Hint:<br>
You can also use normal `docker-compose` commands to maintain your setup.<br/> You can also use normal `docker-compose` commands to maintain your setup.<br>
The only command that you cannot use is `docker-compose build` due to build caching. The only command that you cannot use is `docker-compose build` due to build caching.
### Configuration ### Configuration
All the pleroma options that you usually put into your `*.secret.exs` now go into `config.exs`.<br/> All the pleroma options that you usually put into your `*.secret.exs` now go into `config.exs`.
`.env` stores config values that need to be known at orchestration/build time.<br/>
`.env` stores config values that need to be known at orchestration/build time.<br>
Documentation for the possible values is inside of that file. Documentation for the possible values is inside of that file.
### Updates ### Updates
Run `./pleroma.sh build` again and start the updated image with `./pleroma.sh up`.<br/> Run `./pleroma.sh build` again and start the updated image with `./pleroma.sh up`.
You don't need to stop your pleroma server for either of those commands. You don't need to stop your pleroma server for either of those commands.
### Maintenance ### Maintenance
Pleroma maintenance is usually done with mix tasks.<br/> Pleroma maintenance is usually done with mix tasks.
You can run these tasks in your running pleroma server using `./pleroma.sh mix [task] [arguments...]`.<br/>
For example: `./pleroma.sh mix pleroma.user new sn0w ...`<br/> You can run these tasks in your running pleroma server using `./pleroma.sh mix [task] [arguments...]`.
For example: `./pleroma.sh mix pleroma.user new sn0w ...`
If you need to fix bigger problems you can also spawn a shell with `./pleroma.sh enter`. If you need to fix bigger problems you can also spawn a shell with `./pleroma.sh enter`.
### Postgres Upgrades
Postgres upgrades are a slow process in docker (even more than usual) because we can't utilize `pg_upgrade` in any sensible way.<br/>
If you ever wish to upgrade postgres to a new major release for some reason, here's a list of things you'll need to do.
- Inform your users about the impending downtime
- Seriously this can take anywhere from a couple hours to a week depending on your instance
- Make sure you have enough free disk space or some network drive to dump to, we can't do in-place upgrades
- Stop pleroma (`docker-compose stop server`)
- Dump the current database into an SQL file (`docker-compose exec db pg_dumpall -U pleroma > /my/sql/location/pleroma.sql`)
- Remove the old containers (`docker-compose down`)
- Modify the postgres version in `docker-compose.yml` to your desired release
- Delete `data/db` or move it into some different place (might be handy if you want to abort/revert the migration)
- Start the new postgres container (`docker-compose up -d db`)
- Start the import (`docker-compose exec -T db psql -U pleroma < /my/sql/location/pleroma.sql`)
- Wait for a possibly ridculously long time
- Boot pleroma again (`docker-compose up -d`)
- Wait for service to stabilize while federation catches up
- Done!
### Customization ### Customization
Add your customizations (and their folder structure) to `custom.d/`.<br/> Add your customizations (and their folder structure) to `custom.d/`.<br>
They will be copied into the right place when the container starts.<br/> They will be copied into the right place when the container starts.<br>
You can even replace/patch pleromas code with this, because the project is recompiled at startup if needed. You can even replace/patch pleromas code with this,
because the project is recompiled at startup if needed.
In general: Prepending `custom.d/` to pleromas customization guides should work all the time.<br/> In general: Prepending `custom.d/` to pleromas customization guides should work all the time.<br>
Check them out in the [pleroma documentation](https://docs.pleroma.social/small_customizations.html#content). Check them out in the [pleroma documentation](https://docs.pleroma.social/small_customizations.html#content).
For example: A custom thumbnail now goes into `custom.d/` + `instance/static/instance/thumbnail.jpeg`. For example: A custom thumbnail now goes into `custom.d/` + `priv/static/instance/thumbnail.jpeg`.
### Patches ### Patches
Works exactly like customization, but we have a neat little helper here.<br/> Works exactly like customization, but we have a neat little helper here.
Use `./pleroma.sh mod [regex]` to mod any file that ships with pleroma, without having to type the complete path. Use `./pleroma.sh mod [regex]` to mod any file that ships with pleroma, without having to type the complete path.
### My instance is up, how do I reach it? ### My instance is up, how do I reach it?
To reach Gopher or SSH, just uncomment the port-forward in your `docker-compose.yml`. To reach Gopher or SSH, just uncomment the port-forward in your `docker-compose.yml`.
To reach HTTP you will have to configure a "reverse-proxy".<br/> To reach HTTP you will have to configure a "reverse-proxy".
Older versions of this project contained a huge amount of scripting to support all kinds of reverse-proxy setups.<br/> Older versions of this project contained a huge amount of scripting to support all kinds of reverse-proxy setups.
This newer version tries to focus only on providing good pleroma tooling.<br/> This newer version tries to focus only on providing good pleroma tooling.
That makes the whole process a bit more manual, but also more flexible. That makes the whole process a bit more manual, but also more flexible.
You can use Caddy, Traefik, Apache, nginx, or whatever else you come up with.<br/> You can use Caddy, Traefik, Apache, nginx, or whatever else you come up with.<br>
Just modify your `docker-compose.yml` accordingly. Just modify your `docker-compose.yml` accordingly.
One example would be to add an [nginx server](https://hub.docker.com/_/nginx) to your `docker-compose.yml`: One example would be to add an [nginx server](https://hub.docker.com/_/nginx) to your `docker-compose.yml`:
@ -153,18 +136,18 @@ Then take a look at [the pleroma nginx example](https://git.pleroma.social/plero
Using apache would work in a very similar way (see [Apache Docker Docs](https://hub.docker.com/_/httpd) and [the pleroma apache example](https://git.pleroma.social/pleroma/pleroma/blob/develop/installation/pleroma-apache.conf)). Using apache would work in a very similar way (see [Apache Docker Docs](https://hub.docker.com/_/httpd) and [the pleroma apache example](https://git.pleroma.social/pleroma/pleroma/blob/develop/installation/pleroma-apache.conf)).
The target that you proxy to is called `http://server:4000/`.<br/> The target that you proxy to is called `http://server:4000/`.<br>
This will work automagically when the proxy also lives inside of docker. This will work automagically when the proxy also lives inside of docker.
If you need help with this, or if you think that this needs more documentation, please let me know. If you need help with this, or if you think that this needs more documentation, please let me know.
Something that cofe.rocks uses is simple port-forwarding of the `server` container to the host's `127.0.0.1`.<br/> Something that cofe.rocks uses is simple port-forwarding of the `server` container to the host's `127.0.0.1`.
From there on, the natively installed nginx server acts as a proxy to the open internet.<br/> From there on, the natively installed nginx server acts as a proxy to the open internet.
You can take a look at cofe's [compose yaml](/hosted/pleroma/src/branch/master/docker-compose.yml) and [proxy config](/hosted/pleroma/src/branch/master/proxy.xconf) if that setup sounds interesting. You can take a look at cofe's [compose yaml](https://glitch.sh/hosted/pleroma/src/branch/master/docker-compose.yml#L37) and [proxy config](https://glitch.sh/hosted/pleroma/src/branch/master/proxy.xconf) if that setup sounds interesting.
### Attribution ### Attribution
Thanks to [Angristan](https://github.com/Angristan/dockerfiles/tree/master/pleroma) and [RX14](https://github.com/RX14/kurisu.rx14.co.uk/blob/master/services/iscute.moe/pleroma/Dockerfile) for their dockerfiles, which served as an inspiration for the early versions of this script. Thanks to [Angristan](https://github.com/Angristan/dockerfiles/tree/master/pleroma) and [RX14](https://github.com/RX14/kurisu.rx14.co.uk/blob/master/services/iscute.moe/pleroma/Dockerfile) for their dockerfiles, which served as an inspiration for the early versions of this script.
The current version is based on the [offical install instructions](https://docs.pleroma.social/alpine_linux_en.html). The current version is based on the [offical install instructions](https://docs.pleroma.social/alpine_linux_en.html).<br>
Thanks to all people who contributed to those. Thanks to all people who contributed to those.

View File

@ -2,7 +2,7 @@ version: "3.7"
services: services:
db: db:
image: postgres:13-alpine image: postgres:10-alpine
init: true init: true
restart: unless-stopped restart: unless-stopped
environment: { environment: {
@ -46,5 +46,4 @@ services:
- ./custom.d:/custom.d:ro - ./custom.d:/custom.d:ro
- ./config.exs:/home/pleroma/pleroma/config/prod.secret.exs:ro - ./config.exs:/home/pleroma/pleroma/config/prod.secret.exs:ro
- ./config.exs:/home/pleroma/pleroma/config/dev.secret.exs:ro - ./config.exs:/home/pleroma/pleroma/config/dev.secret.exs:ro
- ./emoji:/home/pleroma/pleroma/instance/static/emoji
- $DOCKER_DATADIR/uploads:/uploads - $DOCKER_DATADIR/uploads:/uploads

View File

@ -1,3 +1,2 @@
CREATE EXTENSION IF NOT EXISTS citext; CREATE EXTENSION IF NOT EXISTS citext;
CREATE EXTENSION IF NOT EXISTS pg_trgm; CREATE EXTENSION IF NOT EXISTS pg_trgm;
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";

View File

@ -196,15 +196,6 @@ action__restart() {
} }
action__start() { action__start() {
if [[ ! -d ./data/uploads ]] || [[ ! -d ./emoji ]]; then
if [[ "$(id -u)" != "$DOCKER_UID" ]]; then
echo "Please create the folders ./data/uploads and ./emoji, and chown them to $DOCKER_UID"
exit 1
fi
mkdir -p ./data/uploads ./emoji
fi
docker_compose up --remove-orphans -d docker_compose up --remove-orphans -d
} }
@ -311,7 +302,7 @@ Actions:
---------------------------- ----------------------------
You can report bugs or contribute to this project at: You can report bugs or contribute to this project at:
https://memleak.eu/sn0w/pleroma-docker https://glitch.sh/sn0w/pleroma-docker
" "
} }