All posts

· 10 min read

Moving away from Firebase Hosting

I decided to deploy my portfolio website on a VPS instead of using Firebase Hosting. In this blog post, I provide a step by step guide on the migration and explain the reason behind this decision.

For a while, Firebase Hosting was my go-to for deploying my portfolio. It's fast to set up, integrates nicely with GitHub Actions, and the free tier is generous enough for a personal site. For a long time, it felt like the obvious choice.

But over time, I started feeling the limits of managed hosting. I wanted more control over my infrastructure, the ability to run multiple services on a single server, and a setup I could actually understand end to end. Firebase was handling too much magic behind the scenes, and I found myself wanting to own that layer myself.

So I moved everything to a VPS on Hetzner. This post explains why, and walks through exactly how I set it up.

Why I Left Firebase Hosting

Firebase Hosting is genuinely great for what it is. Static files, global CDN, automatic SSL — it works out of the box and you barely have to think about it. If all you need is a static site, it's hard to argue against it.

My reasons for leaving were less about Firebase being bad and more about what I wanted going forward. A few things pushed me over the edge:

  • I wanted to host multiple services under one roof without juggling separate Firebase projects
  • I wanted full control over the server environment, networking, and deployment process
  • I wanted to learn how this layer of infrastructure actually works
  • Running a VPS long-term works out cheaper for my use case

None of these are dealbreakers in isolation, but together they made the case for moving to a self-hosted setup. I picked Hetzner because it's affordable, well-regarded, and the interface is refreshingly no-nonsense.

Step 1: Creating the Server

Head to Hetzner, open a project, and create a new server resource. Pick a location close to your audience, choose Ubuntu as the OS, and select Docker from the setup options — it saves you the manual installation step.

If you prefer to install Docker yourself afterwards, the Hetzner community tutorial covers it well.

Step 2: Firewall and SSH

Before anything else, lock down access. From the Hetzner dashboard, open the server's firewall rules and allow these TCP ports:

  • 22 — SSH
  • 80 — HTTP
  • 443 — HTTPS

Create a Non-Root User

Log in as root from the dashboard terminal, then immediately create a dedicated user. Running everything as root is a risk you don't need to take.

adduser holu
usermod -aG sudo holu
usermod -aG docker holu

If the user has no password, allow passwordless sudo by editing /etc/sudoers via visudo:

%sudo   ALL=(ALL:ALL) NOPASSWD: ALL

Then switch to the new user with su - holu and continue from there.

SSH Key Login

Copy your public key into the server's authorized keys file:

mkdir -p ~/.ssh
nano ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh

Test that key-based login works from your local machine before going any further:

ssh holu@<SERVER_IP>

Once confirmed, disable root login and password authentication in /etc/ssh/sshd_config:

PermitRootLogin no
PasswordAuthentication no
sudo systemctl restart ssh

UFW and Fail2Ban

Install UFW and allow only the ports you actually need:

sudo apt update && sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enable

Then install Fail2Ban to automatically block repeated failed login attempts:

sudo apt install fail2ban -y
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

Open jail.local, find the [sshd] section, and ensure it's enabled:

[sshd]
enabled = true
port    = ssh
filter  = sshd
logpath = /var/log/auth.log
maxretry = 5
sudo systemctl enable fail2ban
sudo systemctl start fail2ban

Step 3: Domain and DNS

This is the step that replaces what Firebase Hosting handled automatically. Go to your domain registrar and create an A record pointing your domain to the server IP. Add a CNAME for www if you need it.

Verify propagation with:

dig +short yourdomain.com

Step 4: Deployment with Docker and Caddy

My setup uses Docker Compose for each service, with Caddy as the reverse proxy. All deployment files live under /opt/docker/, and each service gets its own subdirectory.

/opt/docker/
|–– caddy/
|   |–– compose.yaml
|   |–– Caddyfile
|–– webfolio/
    |–– compose.yaml
    |–– .env
    |–– secrets/
        |–– application-secrets.properties

Why Caddy Instead of Nginx?

Caddy handles TLS automatically. It talks to Let's Encrypt, fetches certificates, and renews them — no cron jobs, no manual steps. Coming from Firebase where HTTPS was just there, I wanted something that kept that simplicity on the self-hosted side. Caddy delivers that.

A shared Docker network called proxy connects all services to Caddy. You create it once, and every new service simply joins it.

Setting Up and Deploying

sudo mkdir -p /opt/docker/{caddy,webfolio/secrets}
sudo chown -R $(whoami):docker /opt/docker
chmod 750 /opt/docker /opt/docker/caddy /opt/docker/webfolio /opt/docker/webfolio/secrets

Copy your deployment files from your local machine with scp, SSH in, fill in your domain, environment variables, and secrets. Then set the right permissions — 640 for config files, 600 for anything sensitive.

One thing to watch out for: if your app container runs as a non-root user, it won't be able to read a secrets file owned entirely by your host user. Check which UID the container runs as:

docker inspect your-image:latest | grep -i user

Then adjust ownership so the container can read it:

sudo chown 185:holu /opt/docker/webfolio/secrets/application-secrets.properties
sudo chmod 660 /opt/docker/webfolio/secrets/application-secrets.properties

Create the shared network, start Caddy first, then the app:

docker network create proxy
cd /opt/docker/caddy && docker compose up -d
cd /opt/docker/webfolio && docker compose up -d

Caddy picks up the domain, fetches a certificate, and the site is live at https://yourdomain.com. First deploy done.

Updating and Adding Services

Deploying a new version is two commands:

cd /opt/docker/webfolio
docker compose pull
docker compose up -d

Compose detects the image has changed and recreates only that container. Everything else keeps running. Clean up old images afterwards with:

docker image prune -f

Adding a second site to the same server is just as clean. New directory, new compose.yaml joining the proxy network, a new block in the Caddyfile, and you're done. No touching anything already running, and Caddy provisions the certificate for the new domain automatically.

Was It Worth It?

For my use case, absolutely. I have one server running multiple services, full visibility into how everything is wired together, and I'm paying less than I would scaling up on a managed platform.

That said, Firebase Hosting is still the right call for a lot of situations. If you just want a static site live with zero friction, it's hard to beat. The migration only made sense for me because my needs had grown past what it was designed for.

If you're thinking about making a similar move and have questions about any part of this setup, feel free to reach out.