diff --git a/.gitea/workflows/main-image.yml b/.gitea/workflows/main-image.yml new file mode 100644 index 0000000..59d6536 --- /dev/null +++ b/.gitea/workflows/main-image.yml @@ -0,0 +1,43 @@ +name: Build and Push Image + +on: + push: + branches: + - main + +env: + REGISTRY_HOST: git.campbellwireless.net + IMAGE_NAME: ${{ github.repository }} + +jobs: + docker-build-and-push: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to Gitea registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY_HOST }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Compute image tags + id: tags + run: | + echo "sha_short=$(echo '${{ github.sha }}' | cut -c1-12)" >> "$GITHUB_OUTPUT" + + - name: Build and push image + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:latest + ${{ env.REGISTRY_HOST }}/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.sha_short }} diff --git a/.gitea/workflows/pr-checks.yml b/.gitea/workflows/pr-checks.yml new file mode 100644 index 0000000..a017d22 --- /dev/null +++ b/.gitea/workflows/pr-checks.yml @@ -0,0 +1,32 @@ +name: PR Checks + +on: + pull_request: + +jobs: + lint-test-and-docker-build: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: '1.2.22' + + - name: Install dependencies + run: bun install --frozen-lockfile + + - name: Lint + run: bun run lint + + - name: Unit tests + run: bun run test + + - name: Build app + run: bun run build + + - name: Build Docker image + run: docker build --file Dockerfile --tag trips:pr-${{ github.sha }} . diff --git a/README.md b/README.md index a0da9f5..fb35fc5 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,97 @@ -# sv +# trips -Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli). +A SvelteKit travel planning app for managing trips, travelers, transportation, lodgings, package tours, checklists, and experiences. -## Creating a project +## Tech Stack -If you're seeing this, you've probably already done this step. Congrats! +- SvelteKit + TypeScript +- SQLite (`better-sqlite3`) +- Vitest for unit tests +- ESLint + Prettier for code quality +- Bun for local/deploy build workflows +- Docker multi-stage build for production image + +## Features + +- Authenticated trip dashboard with upcoming/past trip views +- Trip planning with: + - flights + - private vehicles + - other transportation + - lodgings + - package tours + - checklists + - experiences +- Admin flows for travel reference data and tour operator/tour management + +## Local Development + +### Requirements + +- Bun 1.x +- Node.js 22+ (runtime target) + +### Setup ```sh -# create a new project -npx sv create my-app +cp .env.example .env +bun install ``` -## Developing - -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +### Run ```sh -npm run dev - -# or start the server and open the app in a new browser tab -npm run dev -- --open +bun run dev ``` -## Building - -To create a production version of your app: +## Quality and Tests ```sh -npm run build +bun run lint +bun run test +bun run check ``` -You can preview the production build with `npm run preview`. +## Build and Preview -> To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment. +```sh +bun run build +bun run preview +``` + +## Docker + +### Build locally + +```sh +docker build -t trips:local . +``` + +### Run locally + +```sh +docker compose up --build +``` + +The container stores SQLite data at `/data/trips.db` (mounted as the `trips-data` volume in `docker-compose.yml`). + +## CI (Gitea Actions) + +Workflows live in `.gitea/workflows`: + +- `pr-checks.yml`: runs lint, tests, and Docker build on pull requests. +- `main-image.yml`: builds and pushes a Docker image on push to `main`. + +### Registry secrets for image publish + +Configure these repository secrets in Gitea: + +- `REGISTRY_USERNAME` +- `REGISTRY_PASSWORD` + +By default, the publish workflow pushes to: + +- `git.campbellwireless.net//:latest` +- `git.campbellwireless.net//:` + +If your registry host differs, edit `REGISTRY_HOST` in `.gitea/workflows/main-image.yml`.