4.0 KiB
Lean 101 Website
This repo runs as a server-rendered SvelteKit app with a custom Mongo-backed CMS at /admin.
Stack
SvelteKit@sveltejs/adapter-nodeMongoDBvia the nativemongodbdriverdocker composefor local and server runtime
What changed
- The public site now reads page content from MongoDB when
MONGODB_URIandMONGODB_DBare set. - If MongoDB is not configured, the homepage falls back to the local seed file at
src/lib/content/homepage.json. /adminis a custom password-protected editor for:- pages
- movable page sections
- blog posts
- The homepage seed is automatically migrated into the
site_pagescollection the first time the app connects to MongoDB.
Project layout
.
├── Dockerfile
├── docker-compose.yml
├── package.json
├── scripts/
│ └── deploy-do.sh
├── src/
│ ├── app.css
│ ├── app.html
│ ├── lib/
│ │ ├── content/homepage.json
│ │ ├── components/SitePage.svelte
│ │ ├── server/auth.js
│ │ ├── server/content.js
│ │ └── site.js
│ └── routes/
│ ├── +layout.js
│ ├── +page.server.js
│ ├── +page.svelte
│ ├── [slug]/+page.server.js
│ ├── [slug]/+page.svelte
│ ├── admin/+page.server.js
│ ├── admin/+page.svelte
│ ├── blog/+page.server.js
│ ├── blog/+page.svelte
│ ├── blog/[slug]/+page.server.js
│ ├── blog/[slug]/+page.svelte
│ ├── robots.txt/+server.js
│ └── sitemap.xml/+server.js
└── static/assets/
├── lean101-isotipo.png
└── lean101-logotipo.png
Environment variables
Required for the CMS:
MONGODB_URIMONGODB_DBADMIN_PASSWORDADMIN_SESSION_SECRET
Required for correct canonical/meta URLs:
PUBLIC_SITE_URL
Example .env:
PUBLIC_SITE_URL=http://localhost:8080
MONGODB_URI=mongodb://localhost:27017
MONGODB_DB=lean101
ADMIN_PASSWORD=replace-this
ADMIN_SESSION_SECRET=replace-this-with-a-long-random-string
Run locally with Docker
docker compose up --build
The site will be available at http://localhost:8080.
The app server listens on port 3000 inside the container and is mapped to 8080 on the host.
Run locally without Docker
npm install
npm run dev
The Vite dev server will run on its normal local port, usually http://localhost:5173.
Production build
npm run build
npm run preview
npm run preview now runs the built Node server with node build.
Custom CMS
Visit /admin.
The CMS is intentionally simple, but it now supports structured content:
- one password
- multiple pages
- reorderable sections within each page
- blog drafts and published posts
Current collections:
site_pagesblog_posts
Current section types:
heroservicesprocessoutcomeswhyrichTextcta
Published blog posts are available under /blog, and individual pages are available at /<slug>.
DigitalOcean deployment script
After copying this project folder onto a droplet, you can run:
sudo ./scripts/deploy-do.sh --domain yourdomain.com --email you@example.com --with-www
The script:
- installs Docker, the compose plugin, nginx, and certbot
- writes
.envwithPUBLIC_SITE_URL=https://yourdomain.com - starts the compose stack
- configures system nginx to reverse proxy to the Docker app on
127.0.0.1:8080 - requests and installs a Let's Encrypt certificate if
--emailis provided
If you use the CMS in production, make sure the .env file on the server also includes:
MONGODB_URIMONGODB_DBADMIN_PASSWORDADMIN_SESSION_SECRET
Notes
- The current contact CTA still uses
mailto:hello@lean-101.com - The seed homepage remains in
src/lib/content/homepage.json - Live page and blog content is stored in MongoDB once the database env vars are configured