diff --git a/.dockerignore b/.dockerignore index 5f0ee7ad..eb68dba3 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,8 +4,6 @@ !.npmrc !turbo.json !/package.json -!/pnpm-lock.yaml -!/pnpm-workspace.yaml !/apps !/packages !/patches diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 89870f3d..d68e3133 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -8,7 +8,7 @@ Closes #{issueNumber} ## Changsets -Instructions: Changesets automate our changelog. If you modify files in `/packages/ui`, run `pnpm changeset` in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should be `minor` while chores and bugfixes should be `patch`. Please prefix the changeset message with `feat:`, `fix:` or `chore:`. +Instructions: Changesets automate our changelog. If you modify files in `/packages/ui`, run `bun run changeset` in the root of the monorepo, follow the prompts, then commit the markdown file. Changes that add features should be `minor` while chores and bugfixes should be `patch`. Please prefix the changeset message with `feat:`, `fix:` or `chore:`. ## Checklist @@ -17,9 +17,9 @@ Please read and apply all [contribution requirements](../CODE_OF_CONDUCT.md). - [ ] This PR targets the `main` branch - [ ] Documentation reflects all relevant changes - [ ] Branch is prefixed with: `docs/`, `feat/`, `chore/`, `fix/` -- [ ] Ensure Svelte and Typescript linting is current - run `pnpm check` -- [ ] Ensure Prettier linting is current - run `pnpm format` -- [ ] All test cases are passing - run `pnpm test` +- [ ] Ensure Svelte and Typescript linting is current - run `bun run check` +- [ ] Ensure Prettier linting is current - run `bun run format` +- [ ] All test cases are passing - run `bun run test` - [ ] Includes a changeset (if relevant; see above) ### Commit message format diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 079f4acd..5e1c765d 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,44 +28,68 @@ jobs: uses: cocogitto/cocogitto-action@v3.5 with: check-latest-tag-only: true -# linter: -# name: Lint Code Base -# runs-on: ubuntu-latest -# steps: -# - name: Checkout Code -# uses: actions/checkout@v4 -# with: -# # Full git history is needed to get a proper list of changed files within `super-linter` -# fetch-depth: 0 -# - name: Lint Code Base -# uses: github/super-linter@v5 -# env: -# VALIDATE_ALL_CODEBASE: false -# IGNORE_GENERATED_FILES: true -# # FILTER_REGEX_EXCLUDE: CHANGELOG.md -# DEFAULT_BRANCH: main -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} -# build: -# name: Build and Test -# timeout-minutes: 15 -# runs-on: ubuntu-latest -# # To use Remote Caching, uncomment the next lines and follow the steps below. -# env: -# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} -# TURBO_TEAM: ${{ vars.TURBO_TEAM }} + # linter: + # name: Lint Code Base + # runs-on: ubuntu-latest + # steps: + # - name: Checkout Code + # uses: actions/checkout@v4 + # with: + # # Full git history is needed to get a proper list of changed files within `super-linter` + # fetch-depth: 0 + # - name: Lint Code Base + # uses: github/super-linter@v5 + # env: + # VALIDATE_ALL_CODEBASE: false + # IGNORE_GENERATED_FILES: true + # # FILTER_REGEX_EXCLUDE: CHANGELOG.md + # DEFAULT_BRANCH: main + # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # build: + # name: Build and Test + # timeout-minutes: 15 + # runs-on: ubuntu-latest + # # To use Remote Caching, uncomment the next lines and follow the steps below. + # env: + # TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + # TURBO_TEAM: ${{ vars.TURBO_TEAM }} -# steps: -# - name: Check out code -# uses: actions/checkout@v4 -# with: -# fetch-depth: 2 -# - uses: pnpm/action-setup@v2 -# with: -# version: 8 -# - uses: actions/setup-node@v3 -# with: -# node-version: '20' -# cache: 'pnpm' -# - run: pnpm install -# - run: pnpm build -# - run: pnpm test:unit:coverage + # steps: + # - name: Check out code + # uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + # - uses: pnpm/action-setup@v2 + # with: + # version: 8 + # - uses: actions/setup-node@v3 + # with: + # node-version: '20' + # cache: 'pnpm' + # - run: pnpm install + # - run: pnpm run build --filter=playground + # - run: pnpm run test:unit:coverage --filter=playground + + build: + name: Build and Test + timeout-minutes: 15 + runs-on: ubuntu-latest + # To use Remote Caching, uncomment the next lines and follow the steps below. + env: + TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} + TURBO_TEAM: ${{ vars.TURBO_TEAM }} + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 2 + - uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + - name: Install Dependencies + run: bun install + # - run: bun run check --filter=playground + # - run: bun run lint --filter=playground + - run: bun run build --filter=playground + - run: bun run test:unit:coverage --filter=playground diff --git a/.lintstagedrc.cjs b/.lintstagedrc.cjs index ed7c88ff..a612edd1 100644 --- a/.lintstagedrc.cjs +++ b/.lintstagedrc.cjs @@ -1,7 +1,7 @@ /* jshint esversion: 9 */ module.exports = { - '*.{js,ts,json,svelte}': ['pnpm format', 'git add'], - './src/**/*.{svelte,ts}': ['pnpm format', 'git add', 'pnpm lint:fix'], - './.{ts,cjs,js}': ['pnpm lint:fix'] + '*.{js,ts,json,svelte}': ['bun run format', 'git add'], + './src/**/*.{svelte,ts}': ['bun run format', 'git add', 'bun run lint:fix'], + './.{ts,cjs,js}': ['bun run lint:fix'] }; diff --git a/README.md b/README.md index df4e8136..29fef87f 100644 --- a/README.md +++ b/README.md @@ -74,13 +74,13 @@ Use `.env.local` to override environment variables in `.env` (like API keys) for Once you've cloned the project and installed dependencies with `bun i`, start a development server: ```shell -bun run dev --filter=./apps/web +bun run dev --filter=web # or start the server and open the app in a new browser tab -bun run dev --filter=./apps/web -- --open +bun run dev --filter=web -- --open # run in debug mode -bun run dev:debug --filter=./apps/web +bun run dev:debug --filter=web # run with a custom inline config # inline environment variables has higher precedence than ones loaded from .env and .env.local files diff --git a/apps/docs/README.md b/apps/docs/README.md index 374efec4..d22f0515 100644 --- a/apps/docs/README.md +++ b/apps/docs/README.md @@ -16,7 +16,7 @@ npm init svelte my-app ## Developing -Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server: +Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `bun install`), start a development server: ```bash npm run dev diff --git a/apps/web/.dockerignore b/apps/web/.dockerignore index 373ada7b..90ca1bcb 100644 --- a/apps/web/.dockerignore +++ b/apps/web/.dockerignore @@ -5,6 +5,7 @@ !/package.json !/pnpm-lock.yaml !/pnpm-workspace.yaml +!/bun.lockb !/svelte.config.js !/tailwind.config.cjs !/vite.config.js diff --git a/apps/web/houdini.config.js b/apps/web/houdini.config.js index 4b7ab0b6..9ee57eb8 100644 --- a/apps/web/houdini.config.js +++ b/apps/web/houdini.config.js @@ -11,7 +11,7 @@ const defaultMarshall = { const config = { watchSchema: { url: (env) => env.PUBLIC_GRAPHQL_ENDPOINT, - interval: 0, // only pull the schema when you first run `pnpm dev` + interval: 0, // only pull the schema when you first run `bun run dev` // HINT: we need to generate scheam for highest role level that app support. headers: { 'x-hasura-admin-secret': 'env:HASURA_GRAPHQL_ADMIN_SECRET', diff --git a/apps/web/playwright.config.ts b/apps/web/playwright.config.ts index 51b62237..30e57eea 100644 --- a/apps/web/playwright.config.ts +++ b/apps/web/playwright.config.ts @@ -2,7 +2,7 @@ import type { PlaywrightTestConfig } from '@playwright/test'; const config: PlaywrightTestConfig = { webServer: { - command: 'pnpm build && pnpm preview', + command: 'bun run build && bun run preview', port: 4173 }, testDir: 'tests', diff --git a/bun.lockb b/bun.lockb index 53560d2b..dbeeb748 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/cog.toml b/cog.toml index 9ebf4986..a9ff4d69 100644 --- a/cog.toml +++ b/cog.toml @@ -26,7 +26,7 @@ post_bump_hooks = [ [git_hooks.commit-msg] script = """#!/bin/sh set -e -pnpm format +bun run format cog verify -i --file $1 """ diff --git a/docs/turborepo.md b/docs/turborepo.md index 63fc8293..b3a5da1a 100644 --- a/docs/turborepo.md +++ b/docs/turborepo.md @@ -33,8 +33,8 @@ This Turborepo has some additional tools already setup for you: ## Prerequisite ```bash -pnpm add -g turbo@latest -# bun add -g turbo@latest +# pnpm add -g turbo@latest +bun add -g turbo@latest ``` ## Setup diff --git a/pnpm.Dockerfile b/pnpm.Dockerfile new file mode 100644 index 00000000..91444adb --- /dev/null +++ b/pnpm.Dockerfile @@ -0,0 +1,116 @@ +ARG SCOPE=playground +################################################################### +# Stage 0: base image # +################################################################### +FROM node:20-slim AS base +ENV GIT_SSL_NO_VERIFY 1 +RUN apt-get update && apt-get install -y --no-install-recommends git tini + +ARG SCOPE +ENV SCOPE=${SCOPE} + +#https://turbo.build/repo/docs/handbook/deploying-with-docker +#https://github.com/vercel/turbo/tree/main/examples/with-docker + +# Install pnpm +ENV PNPM_HOME="/root/.local/share/pnpm" +ENV PATH="${PATH}:${PNPM_HOME}" +SHELL ["/bin/bash", "-c"] +RUN npm install --global pnpm \ + && SHELL=bash pnpm setup \ + && source /root/.bashrc + +################################################################### +# Stage 1: Prune monorepo # +################################################################### +FROM base AS pruner + +WORKDIR /app +RUN pnpm add -g turbo +COPY . . +RUN turbo prune --scope=${SCOPE} --docker + +################################################################### +# Stage 2: Install dependencies # +# Add lockfile and package.json's of isolated subworkspace # +################################################################### +FROM base AS builder + +WORKDIR /app +# First install the dependencies (as they change less often) +COPY .gitignore .gitignore +COPY --from=pruner /app/out/json/ . +COPY --from=pruner /app/out/pnpm-lock.yaml ./pnpm-lock.yaml + +# https://playwright.dev/docs/browsers +ENV PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD 1 + +RUN pnpm install + +# Build the project +COPY --from=pruner /app/out/full/ . +COPY --from=pruner /app/.git .git +COPY turbo.json turbo.json + +# Uncomment and use build args to enable remote caching +ARG TURBO_TEAM +ENV TURBO_TEAM=$TURBO_TEAM + +ARG TURBO_TOKEN +ENV TURBO_TOKEN=$TURBO_TOKEN + +# TODO: set any extra ENV needed for build +# ENV ENCRYPTION_SECRET=encryption_secret_placeholder123 NEXTAUTH_URL=http://localhost:3000 NEXT_PUBLIC_VIEWER_URL=http://localhost:3001 +RUN pnpm turbo run build --filter=${SCOPE}... + +################################################################### +# Stage 4: Run the app (prod) # +################################################################### +# FROM gcr.io/distroless/nodejs:20 as final +# FROM gcr.io/distroless/nodejs:20-debug as final +FROM cgr.dev/chainguard/node:20 AS runner +# FROM base AS runner + +WORKDIR /app +ENV NODE_ENV production +ARG SCOPE + +# copy tini +COPY --from=builder --chown=node:node /usr/bin/tini /usr/bin/tini +ENTRYPOINT ["/usr/bin/tini", "-s", "--", "/usr/bin/node"] + +# copy runtime needed config files??? +COPY --from=builder --chown=node:node /app/apps/${SCOPE}/package.json . +# COPY --from=builder --chown=node:node /app/config ./config + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=node:node /app/apps/playground/build ./build + + +EXPOSE 3000 +ENV PORT 3000 + +# Metadata params +ARG DOCKER_REGISTRY=ghcr.io +ARG VCS_CONTEXT_PATH=xmlking/spectacular +ARG BUILD_TIME +ARG BUILD_VERSION +ARG VCS_REF=1 +ARG VENDOR=xmlking + +# Metadata +LABEL org.opencontainers.image.created=$BUILD_TIME \ + org.opencontainers.image.name="${SCOPE}" \ + org.opencontainers.image.title="${SCOPE}" \ + org.opencontainers.image.description="Example of SvelteKit multi-stage docker build" \ + org.opencontainers.image.url=https://github.com/$VCS_CONTEXT_PATH \ + org.opencontainers.image.source=https://github.com/$VCS_CONTEXT_PATH \ + org.opencontainers.image.revision=$VCS_REF \ + org.opencontainers.image.version=$BUILD_VERSION \ + org.opencontainers.image.authors=sumanth \ + org.opencontainers.image.vendor=$VENDOR \ + org.opencontainers.image.licenses=MIT \ + org.opencontainers.image.documentation="docker run -it -e NODE_ENV=production -p 3000:3000 ${DOCKER_REGISTRY:+${DOCKER_REGISTRY}/}${VCS_CONTEXT_PATH}/${SCOPE}:${BUILD_VERSION}" + +CMD ["build"] diff --git a/turbo.json b/turbo.json index efef14b3..5b8fcaa0 100644 --- a/turbo.json +++ b/turbo.json @@ -17,9 +17,7 @@ "test:watch": { "cache": false }, - "check": { - "dependsOn": ["format", "lint"] - }, + "check": {}, "clean": { "cache": false },