Tech

Mastodon and Docker Compose
reading time: 2 minutes

Docker Compose

I use Traefik as my reverse proxy. Here is a snippet of my Docker Compose file for Mastodon:

######################
# Mastodon           #
######################
  mastodon-db:
    image: postgres:14-alpine
    container_name: mastodon-db
    shm_size: 256mb
    environment:
      - UID=${PUID}
      - GID=${PGID}
      - TZ=${TZ}
      - POSTGRES_HOST_AUTH_METHOD=trust
    volumes:
      - /root/docker/appdata/mastodon/dbdata:/var/lib/postgresql/data
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
    restart: unless-stopped
  mastodon-redis:
    image: redis:7-alpine
    container_name: mastodon-redis
    environment:
      - UID=${PUID}
      - GID=${PGID}
      - TZ=${TZ}
    volumes:
      - /root/docker/appdata/mastodon/redis:/data
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
    restart: unless-stopped
  mastodon-web:
    image: tootsuite/mastodon
    container_name: mastodon-web
    command: bash -c "rm -f /mastodon/tmp/pids/server.pid; bundle exec rails s -p 3000"
    env_file:
      - .mastodon.env
    environment:
      - UID=${PUID}
      - GID=${PGID}
      - TZ=${TZ}
    volumes:
      - /root/docker/appdata/mastodon/public/system:/mastodon/public/system
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.mastodon-web.rule=Host(`toot.onitato.com`)"
      - "traefik.http.routers.mastodon-web.entrypoints=https"
      - "traefik.http.routers.mastodon-web.tls=true"
      - "traefik.http.routers.mastodon-web.tls.certresolver=letsencrypt"
      - "traefik.http.routers.mastodon-web.middlewares=authelia@docker"
      - "com.centurylinklabs.watchtower.enable=true"
    ports:
      - "3000:3000"
    restart: unless-stopped
    depends_on:
      - traefik
      - mastodon-redis
      - mastodon-db
  mastodon-streaming:
    image: tootsuite/mastodon
    container_name: mastodon-streaming
    command: node ./streaming
    env_file:
      - .mastodon.env
    environment:
      - UID=${PUID}
      - GID=${PGID}
      - TZ=${TZ}
    labels:
      - "traefik.enable=true"
      - "traefik.http.services.mastodon-web.loadbalancer.server.port=4000"
      - "traefik.http.routers.mastodon-streaming.rule=(Host(`toot.onitato.com`) && PathPrefix(`/api/v1/streaming`))"
      - "traefik.http.routers.mastodon-streaming.entrypoints=https"
      - "traefik.http.routers.mastodon-streaming.tls=true"
      - "traefik.http.routers.mastodon-streaming.tls.certresolver=letsencrypt"
      - "traefik.http.routers.mastodon-streaming.middlewares=authelia@docker"
      - "com.centurylinklabs.watchtower.enable=true"
    ports:
      - "4000:4000"
    restart: unless-stopped
    depends_on:
      - traefik
      - mastodon-redis
      - mastodon-db
  mastodon-sidekiq:
    image: tootsuite/mastodon
    container_name: mastodon-sidekiq
    command: bundle exec sidekiq
    env_file:
      - .mastodon.env
    environment:
      - UID=${PUID}
      - GID=${PGID}
      - TZ=${TZ}
    volumes:
      - /root/docker/appdata/mastodon/public/system:/mastodon/public/system
    labels:
      - "com.centurylinklabs.watchtower.enable=true"
    restart: unless-stopped
    depends_on:
      - mastodon-redis
      - mastodon-db

mastodon.env

mastodon.env was generated using these instructions:

Running Chocolatey on Linux
reading time: 1 minute

Update: This docker image is now available on the Docker Hub as linuturk/mono-choco .

Do you want to create Chocolatey packages but don’t want to run a Windows server? Use this Dockerfile to build Chocolatey and do your package development without a Windows system.

FROM mono:3.12.1

MAINTAINER Justin Phelps

RUN apt-get update && apt-get install -y wget unzip

WORKDIR /usr/local/src/choco
RUN wget https://github.com/chocolatey/choco/archive/stable.zip
RUN unzip stable.zip
RUN rm stable.zip

WORKDIR /usr/local/src/choco/choco-stable
RUN chmod +x build.sh
RUN chmod +x zip.sh
RUN ./build.sh

WORKDIR /usr/local/bin
RUN ln -s /usr/local/src/choco/choco-stable/build_output/chocolatey

COPY choco /usr/local/bin/choco

WORKDIR /root

In the same directory as the Dockerfile, place a file called choco with executable permissions. The content of this file should be:

Retrying Server Builds with Ansible
reading time: 1 minute

A common problem with building multiple servers in the cloud is an intermittent failure in one build that can stop your entire deployment process. With the right retry logic you can avoid this problem with Ansible.

I’m using until to check the output from the rax module. Using the length Jinja2 filter, I can check if the correct number of instances have been created. This should retry the task 3 times with a delay of 5 seconds between attempts.

Testing CloudFormation Templates with Ansible
reading time: 4 minutes

There are many variations and combinations of AWS products and services that lend the platform to great flexibility and customization. We work hard to evaluate these combinations and put forth a collection of best practices for our customers to follow. One of these best practices is the use of CloudFormation templates. My team maintains a series of standard CloudFormation templates for our customers to use. Part of that maintenance includes updating those templates and testing them for functionality.