SkillShare Logo
STEP 7 OF 7 · SHIP IT

Run & Deploy

Bring the whole stack up with one commandusing Docker Compose, then push it live. You’re at the finish line.

01 — ONE COMMAND

Run It All with Compose

A single docker-compose.yml at the repo root describes the database, the API, and the web app together.

docker-compose.yml
services:
  db:
    image: postgres:16
    environment:
      POSTGRES_PASSWORD: secret
      POSTGRES_DB: inventory
    ports: ["5432:5432"]
    volumes: ["dbdata:/var/lib/postgresql/data"]

  api:
    build: ./server
    env_file: ./server/.env
    ports: ["4000:4000"]
    depends_on: [db]

  web:
    build: ./web
    ports: ["3000:3000"]
    depends_on: [api]

volumes:
  dbdata:
daily commands
$ docker compose up -d --build   # build + start everything
$ docker compose logs -f         # watch all services
$ docker compose down            # stop (data stays in the volume)
Inside Compose, hostnames change (Postgres only)

For Postgres, containers talk to each other by service name, not localhost. Point the API’s DATABASE_URL at db (e.g. postgresql://postgres:secret@db:5432/inventory) when it runs in Compose. For MongoDB Atlas, your connection string remains unchanged as it points to the cloud database.

Need a Dockerfile?

Each app needs a small Dockerfile(node base image, copy, install, build, start). The Next.js and NestJS docs both publish official examples — search “Dockerfile” on nextjs.org and docs.nestjs.com.

02 — HARDEN

Before You Go Live

A short checklist to flip the app from "works on my machine" to "safe in production".

  • Migrations, not auto-sync — set TypeORM synchronize: false and generate migrations so you never drop data.
  • Strong secrets — a long random JWT_SECRET; never reuse the dev value.
  • Secure cookies — set secure: true and (for cross-site frontends) sameSite: "none" on the login cookie.
  • Lock CORS — set the API’s CORS origin to your real frontend URL with credentials: true.
  • Real email — swap Mailtrap for a production SMTP (Gmail App Password, SendGrid, or Resend).
  • Update CLIENT_URL — verification links and redirects must point at the live domain.
03 — AWS & VERCEL

Step-by-Step Cloud Guide

The professional path: deploy your frontend to Vercel, API server to AWS EC2, and database to AWS (RDS or Docker).

Vercel is the premier platform for static sites and serverless functions, perfect for hosting your web/ directory.

  1. Push your code to a GitHub repository (ensure .env is excluded by .gitignore).
  2. Log in to Vercel and click Add New Project.
  3. Import your GitHub repository.
  4. In the configuration, set the Root Directory to web.
  5. Add any required environment variables (e.g., NEXT_PUBLIC_API_URL pointing to your EC2 backend: http://your-ec2-public-ip:4000).
  6. Click Deploy. Vercel will build and host your frontend on a *.vercel.app domain with SSL enabled.
04 — OTHER HOSTING TARGETS

Alternative Deploy Options

If you prefer quick cloud platforms with built-in databases and simpler interfaces over AWS.

FE

Frontend → Vercel

Ideal for Next.js (same company) and great for Vite SPAs. Connect the GitHub repo, set the root to web/, add env vars, deploy.

BE

Backend → Render / Railway

Deploy the server/ as a web service. Both can also provision a managed database next to it.

PG

Postgres → Neon

Serverless Postgres with a generous free tier. Copy its connection string into DATABASE_URL.

DB

Mongo → MongoDB Atlas

Hosted MongoDB, free shared cluster. Paste its SRV connection string (the mongodb+srv://… URL) into DATABASE_URL (configured in Step 3).

Push to GitHub first

Every host above deploys from a Git repo. git init, commit, create a repo on GitHub, and push — then connect it in each platform’s dashboard.

🎉 — DONE

You Built It

A full inventory system with verified accounts, product CRUD, and automatic low-stock alerts — on the stack of your choice.

  • Users register and must verify their email to log in
  • Logged-in users add, edit, delete, and view products
  • Low stock triggers an automatic email
  • The whole stack runs from one docker compose up
  • It's deployed and reachable on the internet

Where to go next

+

Roles & ownership

Add an owner relation so each user only sees their own products; add an admin role.

+

Product images

Add image uploads with UploadThing and store the URL on the product.

+

Search & pagination

Filter the stock table by name/SKU and page through large catalogs.

+

Tests & CI

Add a few API tests and a GitHub Action so every push is checked automatically.