Pixelfed in Docker

I run pixelfed.de in Docker containers since it’s beginning, but the setup grew over time and became a bit messy.

Now I finally got around to clean it up, and got to a state where – at least I think so – it’s quite simple so I can actually publish it for others to use.

To run your own pixelfed-Instance you’ll need the following docker-compose.yml, a configured env-file and a frontend proxy.

docker-compose.yml

---
version: '2.1'

services:
  app:
    image: zknt/pixelfed
    restart: unless-stopped
    env_file:
      - ./env
    volumes:
      - "app-storage:/var/www/storage"
      - "./env:/var/www/.env"
    depends_on:
      - db
      - redis
    # The port statement makes Pixelfed run on Port 8080, no SSL.
    # For a real instance you need a frontend proxy instead!
    ports:
      - "8080:80"

  worker:
    image: zknt/pixelfed
    restart: unless-stopped
    env_file:
      - ./env
      - "./env:/var/www/.env"
    volumes:
      - "app-storage:/var/www/storage"
    entrypoint: /worker-entrypoint.sh
    depends_on:
      - db
      - redis
      - app
    healthcheck:
      test: php artisan horizon:status | grep running
      interval: 60s
      timeout: 5s
      retries: 1

  db:
    image: zknt/mariadb
    restart: unless-stopped
    env_file:
      - ./env
    environment:
      - MYSQL_ROOT_PASSWORD=changeMeForProduction
    volumes:
      - "db-data:/var/lib/mysql"

  redis:
    image: zknt/redis
    restart: unless-stopped
    volumes:
      - "redis-data:/data"

volumes:
  db-data:
  redis-data:
  app-storage:

env

For your env-file use the .env.docker file from the Pixelfed repo. Simply save it as env next to your docker-compose.yml and fill it in.

Important: Leave APP_KEY empty, it will get filled in automatically at the first start. Set DB_HOST to "db", and choose a random password for DB_PASSWORD before the first start.

If you want your instance to federate, set up a working SSL/HTTPS configuration (in your frontend proxy) and fill in the variables on the block starting with ACTIVITY_PUB.

First start

On the first start of everything the database needs to be initialized. This happens automatically, but takes some seconds.

Start everything with docker-compose up -d and wait for it. You can watch the progress of the start with docker-compose logs -f app.

After the start is complete, register your account through the web interface, and run docker-compose exec app php artisan user:admin YOURUSERNAME to grant yourself admin rights.

Finally

Do not forget to back up your docker volumes, set up SMTP for mailing out, and set up your frontend proxy. I use Traefik for that.

And a last tip:

If you’re experiencing problems you’ll get help on Mastodon (official account is @pixelfed) or via IRC on Freenode, the channel is #pixelfed.

Leave a Reply

Your email address will not be published. Required fields are marked *