Deploy using Docker Compose
You can use Docker compose to deploy a TinyPixel instance
# Prerequisites
- You have a Linux server available that you can SSH into, possibly using DigitalOcean.
- You have Docker and Docker Compose installed on that Linux server. It’s suggested that you use official installation instructions from Docker for your distribution.
- A domain name, or subdomain, with an
Arecord set with your server’s IP.
# Deployment Steps
- First, make sure you have a user with UID
1000set up. You can create one if not:adduser --uid 1000 tiny_pixel --disabled-password usermod -a -G docker tiny_pixel - Next create a docker compose YAML file on your host, typically this
file is named
compose.yml:services: caddy: image: caddy:2-alpine restart: unless-stopped ports: - "80:80" - "443:443" - "443:443/udp" # Optional for HTTP/3 support volumes: - ./Caddyfile:/etc/caddy/Caddyfile - caddy_data:/data - caddy_config:/config web: image: ghcr.io/mjc-gh/tiny_pixel:0.0.1 restart: unless-stopped environment: - TP_DOMAIN_NAME=__REPLACE_WITH_DOMAIN_NAME__ - RAILS_SECRET_KEY_BASE=${RAILS_SECRET_KEY_BASE} volumes: - rails-storage:/rails/storage depends_on: - jobs jobs: image: ghcr.io/mjc-gh/tiny_pixel:0.0.1 restart: unless-stopped command: ./bin/jobs environment: - TP_DOMAIN_NAME=__REPLACE_WITH_DOMAIN_NAME__ - RAILS_SECRET_KEY_BASE=${RAILS_SECRET_KEY_BASE} volumes: - rails-storage:/rails/storage volumes: caddy_data: caddy_config: rails-storage:You will need to replace
__REPLACE_WITH_DOMAIN_NAME__with your actual domain name.You may need to additional environment variables if you are opting to use Email Delivery and other advanced features. Refer to the configuration page for more details.
- Create a
Caddyfilein the same directory as yourcompose.yml. This file configures the reverse proxy:__REPLACE_WITH_DOMAIN_NAME__ { reverse_proxy web:3000 }Replace
__REPLACE_WITH_DOMAIN_NAME__with your actual domain name. - Create a
.envfile in the same directory as yourcompose.ymlwith the required environment variables:RAILS_SECRET_KEY_BASE=For the
RAILS_SECRET_KEY_BASE, you need a random value that is sufficiently secure. The simplest way to generate a good secret key is to run:openssl rand -hex 64Copy the output and paste it as the value for
RAILS_SECRET_KEY_BASEin your.envfile. - Start the Docker Compose services:
docker compose up -d - Once the containers are running, you can reveal your admin URL by
running:
docker exec -it tiny_pixel-web-1 bin/rails tiny_pixel:system_admin_password
Within the system admin, you can create a new login for your TinyPixel instance. Once logged in to the application, you can create new sites, configure them, and add teammates.
# Tips
-
Keep your
.envfile secure: The.envfile contains yourRAILS_SECRET_KEY_BASEsecret. Make sure not to commit it to version control. Consider adding.envto your.gitignore. You can also restrict its permissions withchmod 600 .env. -
Use block storage for reliable backups: Store your
rails-storagevolume on a cloud provider’s block storage (like DigitalOcean volumes) to make automated backups and recovery easier. -
Monitor container logs: Use
docker compose logs -fto view live logs from your containers, which is helpful for debugging issues or monitoring the health of your deployment.