diff --git a/.dockerignore b/.dockerignore index f7c9f5e..f9a969f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,3 +9,15 @@ npm-debug.log data CLAUDE.md docs/ +Budfile +PLAN.md +/backups/ +/data.bak/ +/coverage/ +*.md +!README.md +!CHANGELOG.md +tags +tsconfig.tsbuildinfo +.env.local +.env.*.local diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 index cd7b163..540d733 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1 +1,11 @@ +#!/bin/sh +# Check that package.json version exists in CHANGELOG.md +VERSION=$(node -p "require('./package.json').version") +if ! grep -q "## Version $VERSION" CHANGELOG.md; then + echo "❌ Error: Version $VERSION from package.json not found in CHANGELOG.md" + echo "Please add an entry for version $VERSION in CHANGELOG.md" + exit 1 +fi +echo "✅ Version $VERSION found in CHANGELOG.md" + npm run typecheck && npm run lint && npm run test diff --git a/CHANGELOG.md b/CHANGELOG.md index f4c5760..9f2cad9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Version 0.2.26 + +### Improved + +* Docker build performance optimization with cache mounts + ## Version 0.2.25 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index f195b8b..e8c5ff2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -24,6 +24,15 @@ HabitTrove is a gamified habit tracking PWA built with Next.js 15, TypeScript, a - `docker compose up -d` - Run with docker-compose (recommended) - Requires `AUTH_SECRET` environment variable: `openssl rand -base64 32` +## Version Management + +### Creating a New Version +1. Update version in `package.json` +2. Update `CHANGELOG.md` with new version and changes (follow existing patterns in the file) +3. Run `npm run typecheck && npm run lint` to ensure code quality +4. Commit changes: `git add . && git commit -m "feat: description"` + * Follow Conventional Commits Standard: `[scope]: ` (e.g., `feat(auth): add OAuth integration`, `fix: resolve memory leak in task loader`). + ## Architecture Overview ### State Management (Jotai) @@ -88,4 +97,4 @@ Reference `CoinsManager.tsx:107-119` for admin user selection implementation. Si ## Performance Considerations - State updates use immutable patterns - Large dataset filtering happens at hook level -- Derived atoms prevent unnecessary re-renders \ No newline at end of file +- Derived atoms prevent unnecessary re-renders diff --git a/Dockerfile b/Dockerfile index 3d94229..23481b6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,18 +1,17 @@ # syntax=docker.io/docker/dockerfile:1 -FROM node:18-alpine AS base +# Use build platform for base images to avoid emulation +FROM --platform=$BUILDPLATFORM node:22-alpine AS base # Install dependencies only when needed FROM base AS deps -# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. RUN apk add --no-cache libc6-compat WORKDIR /app -# Install dependencies based on the preferred package manager +# Use cache mounts for npm cache COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./ -RUN \ +RUN --mount=type=cache,target=/root/.npm \ if [ -f yarn.lock ]; then yarn --frozen-lockfile; \ - # use --force flag until all deps supports react19 elif [ -f package-lock.json ]; then npm ci --force; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm i --frozen-lockfile; \ else echo "Lockfile not found." && exit 1; \ @@ -26,32 +25,28 @@ COPY . . ENV NEXT_TELEMETRY_DISABLED=1 -RUN \ +# Use cache mount for Next.js cache +RUN --mount=type=cache,target=/app/.next/cache \ if [ -f yarn.lock ]; then yarn run build; \ elif [ -f package-lock.json ]; then npm run build; \ elif [ -f pnpm-lock.yaml ]; then corepack enable pnpm && pnpm run build; \ else echo "Lockfile not found." && exit 1; \ fi -# Production image, copy all the files and run next -FROM base AS runner +# Production image - use target platform +FROM node:22-alpine AS runner WORKDIR /app ENV NODE_ENV=production ENV NEXT_TELEMETRY_DISABLED=1 -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nextjs - -# Create data and backups directories and set permissions -RUN mkdir -p /app/data /app/backups \ - && chown nextjs:nodejs /app/data /app/backups +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nextjs && \ + mkdir -p /app/data /app/backups && \ + chown nextjs:nodejs /app/data /app/backups COPY --from=builder /app/public ./public COPY --from=builder /app/CHANGELOG.md ./ - -# Automatically leverage output traces to reduce image size -# https://nextjs.org/docs/advanced-features/output-file-tracing COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static diff --git a/package.json b/package.json index a285537..357c233 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "habittrove", - "version": "0.2.25", + "version": "0.2.26", "private": true, "scripts": { "dev": "next dev --turbopack",