Skip to content

Commit

Permalink
switch to pnpm (#378)
Browse files Browse the repository at this point in the history
* switch to pnpm

it's much faster, uses less space on disk
(no gigantic node_modules) and has a readable
lock file

* fixup CI for linting and building

* more fixup

* cleanup dockerfile
  • Loading branch information
skykanin authored Dec 11, 2024
1 parent e7ed0d3 commit 2bf9e7a
Show file tree
Hide file tree
Showing 8 changed files with 4,284 additions and 5,778 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/build-and-lint-on-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: false

- name: Set up node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
cache: 'pnpm'

- name: Install dependencies
run: npm install
run: pnpm install

- name: Build application
run: npm run build
run: pnpm run build

- name: Check for ESLint warnings and errors
run: npm run lint
run: pnpm run lint
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM node:20-alpine AS builder
WORKDIR /usr/local/app
RUN apk add pnpm

COPY . .
RUN npm ci && npm run build

RUN rm -rf node_modules && \
pnpm install && pnpm run build

FROM node:20-alpine

WORKDIR /usr/local/app
RUN apk add pnpm

COPY --from=builder /usr/local/app/dist ./dist
COPY package*.json server.js ./

RUN npm install --ignore-scripts --save-exact express vite-express
RUN pnpm install --ignore-scripts vite-express

ENV PORT=8080
EXPOSE 8080

ENTRYPOINT ["sh", "-c", "./dist/vite-envs.sh && npm run prod"]
ENTRYPOINT ["sh", "-c", "./dist/vite-envs.sh && npm run prod"]
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ help:

.PHONY: build
build: ## Build the app
npm install
pnpm install

build-docker-local:
docker build -t dapla-ctrl .

.PHONY: run-dev
run-dev: ## Run the app in dev mode
npm run dev
pnpm run dev

include .env.local
run-docker-local:
docker run -it -p 8080:8080 -e VITE_JWKS_URI=${VITE_JWKS_URI} dapla-ctrl
docker run -it -p 8080:8080 -e VITE_JWKS_URI=${VITE_JWKS_URI} dapla-ctrl
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ powerful primitives for managing asynchrounous effects in a sane way with strong
```sh
nix develop
```
4. Install NPM packages
4. Install PNPM packages
```sh
npm install
pnpm install
```
5. Start the development server and access the application at http://localhost:3000
```sh
npm run dev
pnpm run dev
```

### Note about local development
Expand All @@ -64,7 +64,7 @@ If you don't want to use the Nix development environment you have to follow thes
- Install nodemon (required to run the development server)

```sh
npm install -g nodemon
pnpm add -g nodemon
```

- Set environment variables needed by the application:
Expand All @@ -78,13 +78,13 @@ If you don't want to use the Nix development environment you have to follow thes
For ensuring code consistency and adhering to coding standards, our project utilizes ESLint and Prettier. To view linting warnings and errors in the console, it's recommended to run the following script during development:

```sh
npm run lint
pnpm run lint
```

To automatically fix linting and formatting issues across all files, you can use the following scripts (Note: While these scripts resolve many ESLint warnings or errors, some issues may require manual intervention):

```sh
npm run lint:fix && npm run lint:format
pnpm run lint:fix && pnpm run lint:format
```

### IDE Support
Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
nodejs
nodePackages.nodemon
nodePackages.typescript-language-server
pnpm
pandoc
];
};
Expand Down
Loading

0 comments on commit 2bf9e7a

Please sign in to comment.