Skip to content
Go back

Deploying a Fastify App with Dokploy

Deploying a Fastify App with Dokploy

Introduction

Dokploy offers a simple Docker-based deployment solution for self-hosted applications. This guide walks through deploying a Fastify app with Dokploy.

Prerequisites

Step 1: Dockerize Fastify App

Create Dockerfile in project root:

# Base image
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm install --production

COPY . .

EXPOSE 3000
CMD ["npm", "start"]

Step 2: Define Dokploy Config

Create dokploy.yaml:

apps:
  fastify-api:
    image: dokploy/fastify-api
    container_name: fastify-api
    dockerfile: Dockerfile
    ports:
      - "3000:3000"
    env:
      NODE_ENV: production
      JWT_SECRET: !ENV JWT_SECRET
    volumes:
      - logs:/app/logs

volumes:
  logs:

Step 3: Add Dokploy Remote

git remote add dokploy dokploy@your-server.com:fastify-api

Step 4: Deploy via Git Push

git push dokploy main

Dokploy will build the image, run the container, and expose port 3000.

Step 5: Monitor and Rollbacks

- Roll back:
  ```bash
dokploy rollback fastify-api

Summary

Deploying Fastify with Dokploy involves adding a Dockerfile, dokploy.yaml, and pushing your repo to the Dokploy remote. Enjoy automated Docker deployments with minimal configuration.


Share this post on:

Previous Post
Setting Up Coolify for Self-Hosted Deployments
Next Post
Publishing Expo Apps to App Store & Play Store