Deploying a Lobsters App
Introduction
Lobsters is an open-source link aggregation and discussion platform written in Ruby on Rails. Deploying Lobsters with a Dockerfile on Klutch.sh gives you reproducible builds, managed secrets, and persistent storage for uploaded assets—all configured from klutch.sh/app. This guide covers installation, repository prep, a production-ready Dockerfile, deployment steps, Nixpacks overrides, sample code snippets, and production tips.
Prerequisites
- A Klutch.sh account (create one)
- A GitHub repository containing your Lobsters code (GitHub is the only supported git source)
- Docker familiarity and Ruby/Rails knowledge
- PostgreSQL credentials (required) and Redis (optional for cache/queues)
- Storage for uploads and logs
For onboarding, see the Quick Start.
Architecture and ports
- Lobsters serves HTTP; set the internal container port to
3000. - PostgreSQL and Redis should run as separate Klutch.sh TCP apps, exposed on port
8000and connected internally on5432and6379. - Persistent storage is recommended for uploads and logs if you keep them on disk.
Repository layout
lobsters/├── app/ # Rails app code├── public/ # Static assets├── config/ # Rails configuration├── Dockerfile # Must be at repo root for auto-detection├── Gemfile├── Gemfile.lock└── .env.example # Template only; no secretsKeep secrets out of Git; store them in Klutch.sh environment variables.
Installation (local) and starter commands
Install dependencies and run locally before pushing to GitHub:
bundle installbundle exec rails db:setupbundle exec rails assets:precompilebundle exec rails server -b 0.0.0.0 -p 3000Optional helper start.sh for portability and Nixpacks fallback:
#!/usr/bin/env bashset -euo pipefailbundle exec rails db:migrateexec bundle exec rails server -b 0.0.0.0 -p 3000Make it executable with chmod +x start.sh.
Dockerfile for Lobsters (production-ready)
Place this Dockerfile at the repo root; Klutch.sh auto-detects it (no Docker selection in the UI):
FROM ruby:3.2-slim
WORKDIR /app
RUN apt-get update && apt-get install -y build-essential libpq-dev nodejs yarn git && \ rm -rf /var/lib/apt/lists/*
COPY Gemfile Gemfile.lock ./RUN bundle config set without 'development test' && bundle install --jobs 4 --retry 3
COPY . .
RUN bundle exec rails assets:precompile
ENV PORT=3000 RAILS_ENV=production
EXPOSE 3000CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0", "-p", "3000"]Notes:
- Add any system packages your app requires (e.g.,
imagemagickfor image processing). - For Nginx + Puma setups, adjust the CMD and include the web server config accordingly.
Environment variables (Klutch.sh)
Set these in the Klutch.sh app settings (Secrets tab) before deploying:
PORT=3000RAILS_ENV=productionDATABASE_URL=postgres://<user>:<password>@<host>:<port>/<db>REDIS_URL=redis://<user>:<password>@<host>:<port>(if using Redis)SECRET_KEY_BASE=<secure-secret>HOSTNAME=example-app.klutch.sh
If you deploy without the Dockerfile and need Nixpacks overrides:
NIXPACKS_BUILD_CMD=bundle install --without development test && bundle exec rails assets:precompileNIXPACKS_START_CMD=bundle exec rails server -b 0.0.0.0 -p 3000NIXPACKS_RUBY_VERSION=3.2
These keep Lobsters compatible with Nixpacks defaults when a Dockerfile is absent.
Attach persistent volumes
In Klutch.sh storage settings, add mount paths and sizes (no names required):
/app/public/system— for uploaded files./app/log— optional if you persist logs locally.
Ensure these paths are writable inside the container.
Deploy Lobsters on Klutch.sh (Dockerfile workflow)
- Push your repository (with the Dockerfile at the root) to GitHub.
- Open klutch.sh/app, create a project, and add an app.
- Connect the GitHub repository; Klutch.sh automatically detects the Dockerfile.
- Choose HTTP traffic for Lobsters.
- Set the internal port to
3000. - Add the environment variables above (DB/Redis URLs, secret key, hostname, and any
NIXPACKS_*overrides if you temporarily deploy without the Dockerfile). - Attach persistent volumes for
/app/public/system(and/app/logif used), selecting sizes that fit your uploads and logging needs. - Deploy. Your Lobsters instance will be reachable at
https://example-app.klutch.sh; attach a custom domain if desired.
Sample API usage
Fetch the front page JSON feed (if enabled):
curl -X GET "https://example-app.klutch.sh/hottest.json"Health checks and production tips
- Add a reverse proxy probe to
/or a lightweight status route. - Enforce HTTPS at the edge; forward HTTP to port 3000 internally.
- Keep image and dependency versions pinned; upgrade intentionally with DB backups.
- Monitor disk usage on
/app/public/systemand resize volumes before they fill. - Back up PostgreSQL and uploaded files regularly; do not rely on container filesystems for durability.
Lobsters on Klutch.sh combines reproducible Docker builds with managed secrets, persistent storage for uploads, and flexible HTTP/TCP routing. With the Dockerfile at the repo root and port 3000 configured, you can run a reliable community link aggregator without extra YAML or workflow overhead.