Skip to content

Commit 3b8c070

Browse files
committed
Refresh the setup
1 parent cd571c7 commit 3b8c070

25 files changed

+1875
-2560
lines changed

.devcontainer/compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
services:
2+
workspace:
3+
build:
4+
dockerfile: ./Dockerfile
5+
context: ..
6+
target: workspace
7+
command: /bin/sh -c "while sleep 1000; do :; done"
8+
volumes:
9+
- ..:/app
10+
# Persist home directory over rebuilds,
11+
# but also make VSCode reinstall extensions on rebuild.
12+
- profile:/home/node
13+
- /home/node/.vscode-server
14+
15+
emulator:
16+
image: ghcr.io/badrap/emulator:0.19.10
17+
environment:
18+
APP_URL: http://workspace:4005/app
19+
20+
volumes:
21+
profile:

.devcontainer/devcontainer.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"name": "typescript-example-app",
3-
"dockerComposeFile": ["../compose.yml"],
2+
"name": "@repo/app",
3+
"dockerComposeFile": ["./compose.yml"],
44
"service": "workspace",
5-
"shutdownAction": "none",
5+
"shutdownAction": "stopCompose",
66
"remoteUser": "node",
77
"workspaceFolder": "/app",
8+
"postCreateCommand": "pnpm i",
9+
"postStartCommand": "pnpm dev:init",
10+
"forwardPorts": ["emulator:4004", "workspace:4005", "mailpit:8025"],
811
"customizations": {
912
"vscode": {
1013
"extensions": [

.dockerignore

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1-
node_modules
21
npm-debug.log
3-
Dockerfile*
4-
compose*
2+
**/Dockerfile*
53
.dockerignore
64
.git
7-
.gitignore
85
README.md
96
LICENSE
107
.devcontainer
118
.github
129
.vscode
1310
deployments
1411
helm-chart
15-
dist
16-
.eslintrc.json
17-
.env*
12+
**/dist
13+
**/test
14+
**/tests
15+
**/.next
16+
**/node_modules
17+
**/.pnpm-store
18+
**/.cache
19+
out
20+
**/.env
21+
**/.env.*
22+
**/*.env

.github/workflows/main.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test, build and deploy
2+
3+
on: [push]
4+
5+
# Disable all permissions by default, requiring explicit permission definitions for all jobs.
6+
permissions: {}
7+
8+
jobs:
9+
check:
10+
name: Lint & typecheck
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
steps:
15+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
16+
with:
17+
fetch-depth: 2
18+
persist-credentials: false
19+
- name: Install correct Node.js version
20+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
21+
with:
22+
node-version: 24
23+
- name: Install correct pnpm version
24+
run: corepack enable
25+
- name: Enable pnpm caching (requires that correct Node.js and pnpm versions are already installed)
26+
uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
27+
with:
28+
cache: pnpm
29+
- run: pnpm i --frozen-lockfile
30+
- name: Lint & typecheck
31+
run: |
32+
pnpm run typecheck
33+
pnpm run lint

.gitignore

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ npm-debug.log*
55
yarn-debug.log*
66
yarn-error.log*
77
lerna-debug.log*
8+
.pnpm-debug.log*
89

910
# Diagnostic reports (https://nodejs.org/api/report.html)
1011
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -41,8 +42,8 @@ build/Release
4142
node_modules/
4243
jspm_packages/
4344

44-
# TypeScript v1 declaration files
45-
typings/
45+
# Snowpack dependency directory (https://snowpack.dev/)
46+
web_modules/
4647

4748
# TypeScript cache
4849
*.tsbuildinfo
@@ -53,6 +54,9 @@ typings/
5354
# Optional eslint cache
5455
.eslintcache
5556

57+
# Optional stylelint cache
58+
.stylelintcache
59+
5660
# Microbundle cache
5761
.rpt2_cache/
5862
.rts2_cache_cjs/
@@ -68,29 +72,41 @@ typings/
6872
# Yarn Integrity file
6973
.yarn-integrity
7074

71-
# dotenv environment variables file
75+
# dotenv environment variable files
7276
.env
73-
.env.test
77+
.env.development.local
78+
.env.test.local
79+
.env.production.local
80+
.env.local
7481

7582
# parcel-bundler cache (https://parceljs.org/)
7683
.cache
84+
.parcel-cache
7785

7886
# Next.js build output
7987
.next
88+
out
8089

8190
# Nuxt.js build / generate output
8291
.nuxt
8392
dist
8493

8594
# Gatsby files
8695
.cache/
87-
# Comment in the public line in if your project uses Gatsby and *not* Next.js
96+
# Comment in the public line in if your project uses Gatsby and not Next.js
8897
# https://nextjs.org/blog/next-9-1#public-directory-support
8998
# public
9099

91100
# vuepress build output
92101
.vuepress/dist
93102

103+
# vuepress v2.x temp and cache directory
104+
.temp
105+
.cache
106+
107+
# Docusaurus cache and generated files
108+
.docusaurus
109+
94110
# Serverless directories
95111
.serverless/
96112

@@ -102,3 +118,17 @@ dist
102118

103119
# TernJS port file
104120
.tern-port
121+
122+
# Stores VSCode versions used for testing VSCode extensions
123+
.vscode-test
124+
125+
# yarn v2
126+
.yarn/cache
127+
.yarn/unplugged
128+
.yarn/build-state.yml
129+
.yarn/install-state.gz
130+
.pnp.*
131+
132+
.pnpm-store
133+
dist
134+
*.local.env

.npmrc

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

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

.vscode/settings.json

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,25 @@
11
{
2-
"typescript.tsdk": "./node_modules/typescript/lib",
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": "explicit"
4+
},
5+
"editor.defaultFormatter": "esbenp.prettier-vscode",
36
"editor.formatOnSave": true,
47
"editor.tabSize": 2,
5-
"eslint.format.enable": true,
6-
"explorer.excludeGitIgnore": true,
7-
"[json][jsonc]": {
8-
"editor.defaultFormatter": "esbenp.prettier-vscode"
8+
"files.exclude": {
9+
"**/node_modules": true,
10+
"**/.pnpm-store": true,
11+
"**/.cache": true,
12+
"**/dist": true
13+
},
14+
"files.watcherExclude": {
15+
"**/.git/objects/**": true,
16+
"**/.git/subtree-cache/**": true,
17+
"**/node_modules/**": true,
18+
"**/.pnpm-store/**": true,
19+
"**/.cache": true,
20+
"**/dist/**": true
921
},
10-
"[javascript][javascriptreact][typescript][typescriptreact]": {
11-
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
12-
}
22+
"typescript.tsdk": "node_modules/typescript/lib",
23+
"prettier.trailingComma": "all",
24+
"npm.packageManager": "pnpm"
1325
}

Dockerfile

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,58 @@
11
# Define the base image used for the rest of the steps
2-
FROM node:22-alpine AS base
2+
FROM node:24.13.0-alpine AS base
3+
# Install Corepack to manage the package manager version. The --force
4+
# flag is required to allow overriding pre-existing npm and yarn binaries.
5+
RUN npm install --global --force corepack
36
RUN apk add --no-cache tini
47
ENTRYPOINT ["/sbin/tini", "--"]
58
RUN mkdir /app && chown node:node app
6-
# Run as uid=1000(node)
9+
# Run as uid=1000(node) - The user needs to be numeric so that Kubernetes
10+
# can verify user is non-root when securityContext.runAsNonRoot is true.
711
USER 1000
812
WORKDIR /app
13+
# Ensure that the correct version of pnpm is installed
14+
COPY --chown=node:node package.json ./
15+
RUN corepack install \
16+
&& rm package.json
917

10-
# Visual Studio Code workspace tools
18+
# Visual Studio Code workspace tools & dependencies
1119
FROM base AS workspace
1220
USER root
1321
RUN apk add --no-cache \
22+
bash \
1423
curl \
1524
git \
1625
httpie \
1726
openssh \
1827
ripgrep
1928
# Run as uid=1000(node)
2029
USER 1000
30+
# Allow npm and pnpm to install packages with --global without sudo.
31+
RUN mkdir ~/.npm-global \
32+
&& mkdir -p ~/.pnpm-global/bin \
33+
&& npm config set -L user prefix ~/.npm-global \
34+
&& pnpm config set -g global-bin-dir ~/.pnpm-global/bin
2135
ENV NODE_ENV=development
36+
ENV PATH="$PATH:/home/node/.local/bin:/home/node/.npm-global/bin:/home/node/.pnpm-global/bin"
37+
# Create directories before (anonymous or named) volumes are be mounted
38+
# to them, so that the ownership will be correct.
39+
RUN mkdir ~/.vscode-server
2240

23-
# Collect development dependencies
24-
FROM base AS dev
25-
COPY --chown=node:node .npmrc package.json package-lock.json /app/
26-
RUN npm ci --no-audit --no-fund
41+
FROM base AS dev-deps
42+
COPY --chown=node:node package.json pnpm-workspace.yaml pnpm-lock.yaml ./
43+
RUN pnpm i --frozen-lockfile
2744

28-
# Collect production dependencies
29-
FROM dev AS prod
30-
RUN npm ci --omit=dev --no-audit --no-fund
45+
FROM dev-deps AS prod-deps
46+
RUN pnpm i --prod --frozen-lockfile
3147

32-
# Build the production code
33-
FROM dev AS build
34-
COPY --chown=node:node . /app
35-
RUN npm run build
48+
FROM dev-deps AS build
49+
COPY --chown=node:node . .
50+
RUN pnpm build
3651

3752
# Final image, collect the production code & dependencies
3853
FROM base
39-
COPY --from=prod --chown=node:node /app/node_modules /app/node_modules
40-
COPY --from=build --chown=node:node /app/dist /app/dist
54+
COPY --chown=node:node package.json pnpm-workspace.yaml ./
55+
COPY --chown=node:node --from=prod-deps /app/node_modules ./node_modules
56+
COPY --chown=node:node --from=build /app/dist ./dist
4157
ENV NODE_ENV=production
42-
CMD ["node", "--enable-source-maps", "dist/index.js"]
58+
CMD ["node", "--run", "start"]

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Badrap Oy
3+
Copyright (c) 2026 Badrap Oy
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)