Skip to content

Commit 38eab1b

Browse files
authored
Merge pull request #8 from danangekal/feature/update-tech-stacks
feat: update tech stack latest (node, pnpm, react, next, etc)
2 parents 439fa99 + 64d464a commit 38eab1b

24 files changed

Lines changed: 1775 additions & 4981 deletions

.dockerignore

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules
33

44
# next.js
55
.next
6+
out
67

78
# vercel
89
.vercel
@@ -15,14 +16,27 @@ node_modules
1516
npm-debug.log*
1617
yarn-debug.log*
1718
yarn-error.log*
19+
pnpm-debug.log*
1820

1921
# local env files
20-
.env.local
21-
.env.development.local
22-
.env.test.local
23-
.env.production.local
22+
.env*.local
2423

25-
# docker file
24+
# docker files
2625
Dockerfile
2726
docker-compose.yml
2827
kubernetes-deployment.yml
28+
29+
# git
30+
.git
31+
.gitignore
32+
33+
# IDE
34+
.vscode
35+
.idea
36+
37+
# testing
38+
coverage
39+
40+
# docs
41+
README.md
42+
CLAUDE.md

.eslintrc.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 66 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,85 @@
1-
# This is a basic workflow to help you get started with Actions
1+
name: CI/CD Pipeline
22

3-
name: CI to Docker Hub
4-
5-
# Controls when the action will run.
63
on:
7-
# Triggers the workflow on push or pull request events but only for the main branch
84
push:
9-
branches: [ main ]
5+
branches: [main]
106
pull_request:
11-
branches: [ main ]
12-
13-
# Allows you to run this workflow manually from the Actions tab
7+
branches: [main]
148
workflow_dispatch:
159

16-
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1710
jobs:
18-
# This workflow contains a single job called "build"
19-
build:
20-
# The type of runner that the job will run on
11+
lint-and-test:
2112
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup pnpm
18+
uses: pnpm/action-setup@v4
19+
20+
- name: Setup Node.js
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: '22'
24+
cache: 'pnpm'
25+
26+
- name: Install dependencies
27+
run: pnpm install --frozen-lockfile
28+
29+
- name: Run Biome checks
30+
run: pnpm lint
2231

23-
# Steps represent a sequence of tasks that will be executed as part of the job
32+
- name: Type check
33+
run: pnpm type-check
34+
35+
- name: Run tests
36+
run: pnpm test
37+
38+
build:
39+
runs-on: ubuntu-latest
40+
needs: lint-and-test
2441
steps:
25-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
26-
- name: Check Out Repo
27-
uses: actions/checkout@v2.3.4
42+
- name: Checkout code
43+
uses: actions/checkout@v4
44+
45+
- name: Setup pnpm
46+
uses: pnpm/action-setup@v4
2847

29-
# Set up cache for the builder
30-
- name: Cache Docker layers
31-
uses: actions/cache@v2.1.4
48+
- name: Setup Node.js
49+
uses: actions/setup-node@v4
3250
with:
33-
path: /tmp/.buildx-cache
34-
key: ${{ runner.os }}-buildx-${{ github.sha }}
35-
restore-keys: |
36-
${{ runner.os }}-buildx-
37-
38-
# Login to docker
39-
- name: Docker Login
40-
uses: docker/login-action@v1.8.0
51+
node-version: '22'
52+
cache: 'pnpm'
53+
54+
- name: Install dependencies
55+
run: pnpm install --frozen-lockfile
56+
57+
- name: Build application
58+
run: pnpm build
59+
60+
docker:
61+
runs-on: ubuntu-latest
62+
needs: build
63+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Set up Docker Buildx
69+
uses: docker/setup-buildx-action@v3
70+
71+
- name: Login to Docker Hub
72+
uses: docker/login-action@v3
4173
with:
4274
username: ${{ secrets.DOCKER_HUB_USERNAME }}
4375
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
4476

45-
# Set up docker buildx
46-
- name: Docker Setup Buildx
47-
uses: docker/setup-buildx-action@v1.1.1
48-
49-
# Build and push docker images
50-
- name: Build and push Docker images
51-
uses: docker/build-push-action@v2.3.0
77+
- name: Build and push Docker image
78+
uses: docker/build-push-action@v6
5279
with:
53-
context: ./
80+
context: .
5481
file: ./Dockerfile
55-
builder: ${{ steps.buildx.outputs.name }}
5682
push: true
57-
tags: danangekal/next-typescript-pwa-starter:latest
58-
cache-from: type=local,src=/tmp/.buildx-cache
59-
cache-to: type=local,dest=/tmp/.buildx-cache
60-
61-
- name: Image digest
62-
run: echo ${{ steps.docker_build.outputs.digest }}
83+
tags: danangekal/next-typescript-pwa-starter:latest
84+
cache-from: type=gha
85+
cache-to: type=gha,mode=max

.husky/pre-commit

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
#!/bin/sh
2-
. "$(dirname "$0")/_/husky.sh"
3-
4-
npx lint-staged
1+
pnpm lint-staged

.husky/prepare-commit-msg

Lines changed: 0 additions & 4 deletions
This file was deleted.

.lintstagedrc.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
{
2-
"*.{css,scss,json,md,html}": "prettier --ignore-path .gitignore --write",
3-
"*.{js,ts,tsx}": [
4-
"prettier --ignore-path .gitignore --write",
5-
"eslint --ignore-path .gitignore --quiet --fix"
6-
]
2+
"*": "biome check --no-errors-on-unmatched --files-ignore-unknown=true"
73
}

.prettierrc.json

Lines changed: 0 additions & 11 deletions
This file was deleted.

CLAUDE.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
Next.js 15 + React 19 + TypeScript + PWA starter template with strict TypeScript configuration and Biome for code quality.
8+
9+
**Key Technologies:**
10+
- Next.js 15.5.4 (Pages Router) with Turbopack
11+
- React 19.2.0
12+
- TypeScript 5.7 with strict mode enabled
13+
- Serwist (successor to next-pwa) for Progressive Web App functionality
14+
- Biome for linting and formatting
15+
- pnpm for package management
16+
17+
## Common Commands
18+
19+
### Development
20+
```bash
21+
pnpm dev # Start development server with Turbopack (PWA disabled in dev)
22+
pnpm type-check # Run TypeScript type checking without emitting files
23+
pnpm type-check:watch # Run TypeScript type checking in watch mode
24+
pnpm lint # Run Biome lint checks on the codebase
25+
pnpm format # Format all code with Biome
26+
pnpm check # Run Biome lint and format (auto-fix) on the codebase
27+
pnpm telemetry # Check Next.js telemetry status
28+
```
29+
30+
### Build & Production
31+
```bash
32+
pnpm build # Build production bundle
33+
pnpm start # Start production server (requires build first)
34+
```
35+
36+
### Docker
37+
```bash
38+
docker build -t next-typescript-pwa-starter .
39+
docker run --rm -it -p 3000:3000 next-typescript-pwa-starter
40+
docker-compose up
41+
```
42+
43+
## Architecture
44+
45+
### Directory Structure
46+
- `pages/` - Next.js Pages Router
47+
- `_app.tsx` - Custom App component
48+
- `_document.tsx` - Custom Document component
49+
- `api/` - API routes
50+
- `index.tsx` - Home page
51+
- `components/` - React components (e.g., nav.tsx)
52+
- `styles/` - CSS/styling files
53+
- `public/` - Static assets and PWA manifest
54+
- `sw.js` - Service worker source file
55+
56+
### PWA Configuration
57+
PWA functionality is configured using **Serwist** (next-pwa successor):
58+
- Configuration in `next.config.js` using `@serwist/next`
59+
- Service worker source: `sw.js` (root) → builds to `public/sw.js`
60+
- **Disabled** in development mode (only works in production)
61+
- Manifest file: `public/manifest.json`
62+
- PWA meta tags and manifest link in `pages/_document.tsx`
63+
- Icons located in `public/icons/`
64+
65+
### TypeScript Configuration
66+
Strict TypeScript settings enforced:
67+
- `strict: true` with all strict flags enabled
68+
- `noUnusedLocals` and `noUnusedParameters` enabled
69+
- Path alias `@/*` maps to project root
70+
- Target: ES5, Module: ESNext
71+
72+
### Code Quality with Biome
73+
Pre-commit hooks automatically run via Husky + lint-staged:
74+
- Configuration in `biome.json` and `.lintstagedrc.json`
75+
- Husky hook in `.husky/pre-commit` runs `pnpm lint-staged`
76+
- lint-staged runs Biome checks on staged files only
77+
78+
Biome rules of note:
79+
- `noConsoleLog: error` - Console.log statements are errors
80+
- `noUnusedVariables: error` - Unused variables are errors
81+
- `noExplicitAny: warn` - Explicit any types trigger warnings
82+
- Auto-organizes imports
83+
84+
### CI/CD with GitHub Actions
85+
GitHub Actions workflow (`.github/workflows/main.yml`) runs on push/PR:
86+
1. **lint-and-test** job: Runs Biome checks, type checking, and tests
87+
2. **build** job: Builds the Next.js application
88+
3. **docker** job: Builds and pushes Docker image (main branch only)
89+
90+
## Node & Package Manager Requirements
91+
- Node >= 22.0.0
92+
- pnpm >= 9.0.0 (packageManager: pnpm@9.15.3)
93+
94+
## Important Notes
95+
- This project uses the **Pages Router** (Next.js 15), not the App Router
96+
- **Turbopack** is enabled by default for faster development builds (`pnpm dev --turbopack`)
97+
- PWA features only work in production builds (Serwist disabled in dev)
98+
- No test framework is configured yet (test script is a placeholder)
99+
- Console.log statements will fail Biome checks - remove before committing
100+
- Uses Serwist instead of next-pwa for better Next.js 15 compatibility

Dockerfile

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,60 @@
1-
# Set image from base on offical node lts alpine
2-
ARG VERSION=lts-alpine
3-
FROM node:$VERSION
1+
# Use Node.js 22 Alpine as base image
2+
FROM node:22-alpine AS base
43

5-
# Set label maintainer, version & description
6-
LABEL maintainer="danangekal@gmail.com"
7-
LABEL version="0.1.0"
8-
LABEL description="Unofficial Next.js + Typescript + PWA starter with a latest package"
4+
# Install pnpm
5+
RUN corepack enable && corepack prepare pnpm@10.0.0 --activate
96

10-
# Set working directory
7+
# Dependencies stage
8+
FROM base AS deps
119
WORKDIR /app
1210

13-
# Copy all files
14-
COPY . .
11+
# Copy package files
12+
COPY package.json pnpm-lock.yaml ./
1513

1614
# Install dependencies
17-
RUN yarn install --frozen-lockfile
15+
RUN pnpm install --frozen-lockfile
16+
17+
# Builder stage
18+
FROM base AS builder
19+
WORKDIR /app
1820

19-
# Build app
20-
RUN yarn build
21+
# Copy dependencies and source
22+
COPY --from=deps /app/node_modules ./node_modules
23+
COPY . .
24+
25+
# Build application
26+
RUN pnpm build
27+
28+
# Runner stage
29+
FROM base AS runner
30+
WORKDIR /app
2131

22-
# Expose the listening port
32+
# Set labels
33+
LABEL maintainer="danangekal@gmail.com"
34+
LABEL version="0.1.0"
35+
LABEL description="Next.js 15 + React 19 + TypeScript + PWA starter with Biome and pnpm"
36+
37+
# Set production environment
38+
ENV NODE_ENV=production
39+
40+
# Create non-root user
41+
RUN addgroup --system --gid 1001 nodejs
42+
RUN adduser --system --uid 1001 nextjs
43+
44+
# Copy built application
45+
COPY --from=builder /app/public ./public
46+
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
47+
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
48+
49+
# Switch to non-root user
50+
USER nextjs
51+
52+
# Expose port
2353
EXPOSE 3000
2454

25-
# Run yarb start script when container starts
26-
CMD yarn start
55+
# Set environment variables
56+
ENV PORT=3000
57+
ENV HOSTNAME="0.0.0.0"
58+
59+
# Start application
60+
CMD ["node", "server.js"]

0 commit comments

Comments
 (0)