Skip to content

SvelteKit example project with local HMR + SSL using Docker + NGINX

Notifications You must be signed in to change notification settings

woollysammoth/sveltekit-docker-nginx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SvelteKit Docker NGINX

SvelteKit-Docker-NGINX

This template allows you to have NGINX proxy requests to your SvelteKit app,
while keeping Hot Module Replacement (HMR) and SSL functional with your development environment.

Features

setup-server.sh

  • Installs Docker/Compose dependencies and enables HTTP/HTTPS traffic

setup-ssl.sh

  • This script allows production NGINX to start by creating the requisite dummy Certbot certificate, starting NGINX and finally replacing the dummy certificate with a live certificate. This prevents us from having to modify NGINX's production default.conf when deploying.

USE_POLLING/CHOKIDAR_USEPOLLING

  • true - Windows development environment (fixes an issue with endless HMR reloads)
  • false - Mac/Linux development environment

Usage

Development

  • Create a private key and certificate using mkcert
    • mkcert -install -key-file local.key.pem -cert-file local.cert.pem localhost foo.local
      
    • nginx/dev/local.cert.pem & nginx/dev/local.key.pem need to be created
    • On Mac OS, add key to system keychains in Keychain Access

Production

  • Replace example.com with your domain name in:
    • nginx/prod/default.conf
    • setup-ssl.sh
  • Replace example@example.com with your email address in setup-ssl.sh
  • chmod +x setup-server.sh setup-ssl.sh
  • sudo ./setup-server.sh
  • sudo ./setup-ssl.sh
  • docker compose up --build --force-recreate -d