Add deployment automation and update documentation
This commit is contained in:
80
README.md
80
README.md
@@ -1,38 +1,76 @@
|
||||
# sv
|
||||
# jnss-web
|
||||
|
||||
Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
|
||||
Static website for jnss.me - built with SvelteKit and deployed via Caddy.
|
||||
|
||||
## Creating a project
|
||||
## Project Structure
|
||||
|
||||
If you're seeing this, you've probably already done this step. Congrats!
|
||||
This project uses a **two-branch deployment strategy**:
|
||||
|
||||
- **`main` branch**: Source code and development
|
||||
- Contains all source files, configuration, and build tooling
|
||||
- `build/` directory is gitignored
|
||||
- **`deploy` branch**: Orphan branch with build outputs only
|
||||
- Contains only the static build artifacts (index.html, _app/, etc.)
|
||||
- No source code or build dependencies
|
||||
- Used by Ansible/Caddy for serving the site
|
||||
|
||||
## Development
|
||||
|
||||
Install dependencies:
|
||||
```sh
|
||||
# create a new project in the current directory
|
||||
npx sv create
|
||||
|
||||
# create a new project in my-app
|
||||
npx sv create my-app
|
||||
bun install
|
||||
```
|
||||
|
||||
## Developing
|
||||
|
||||
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
|
||||
|
||||
Start development server:
|
||||
```sh
|
||||
npm run dev
|
||||
bun run dev
|
||||
|
||||
# or start the server and open the app in a new browser tab
|
||||
npm run dev -- --open
|
||||
# or open in browser automatically
|
||||
bun run dev -- --open
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
To create a production version of your app:
|
||||
|
||||
Build the static site:
|
||||
```sh
|
||||
npm run build
|
||||
bun run build
|
||||
```
|
||||
|
||||
You can preview the production build with `npm run preview`.
|
||||
Preview the production build locally:
|
||||
```sh
|
||||
bun run preview
|
||||
```
|
||||
|
||||
> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.
|
||||
## Deployment
|
||||
|
||||
This project uses an automated deployment script that builds and pushes to the `deploy` branch:
|
||||
|
||||
```sh
|
||||
# Deploy with auto-generated timestamp commit message
|
||||
./deploy.sh
|
||||
|
||||
# Deploy with custom commit message
|
||||
./deploy.sh "Add new feature X"
|
||||
```
|
||||
|
||||
**What the script does:**
|
||||
1. Builds the site on the `main` branch (`bun run build`)
|
||||
2. Switches to the `deploy` branch
|
||||
3. Clears old build files
|
||||
4. Moves new build output to the root of `deploy` branch
|
||||
5. Commits and pushes to `origin/deploy`
|
||||
6. Switches back to `main` branch
|
||||
|
||||
**For rick-infra:**
|
||||
The Ansible role clones the `deploy` branch to get production-ready static files:
|
||||
```sh
|
||||
git clone -b deploy git@jnss.me:joakim/jnss-web.git
|
||||
```
|
||||
|
||||
## Tech Stack
|
||||
|
||||
- **Framework**: SvelteKit 2.x with static adapter
|
||||
- **Build Tool**: Vite 7.x
|
||||
- **Package Manager**: Bun
|
||||
- **Deployment**: Two-branch strategy (main → source, deploy → build artifacts)
|
||||
- **Hosting**: Caddy (configured via rick-infra)
|
||||
|
||||
Reference in New Issue
Block a user