Skip to content

Commit

Permalink
Switch to PNPM (#58)
Browse files Browse the repository at this point in the history
* change all references of npm

* Cache pnpm modules

* yeet package-lock.json
  • Loading branch information
hhvrc authored Oct 17, 2024
1 parent 9629701 commit 1980b74
Show file tree
Hide file tree
Showing 12 changed files with 5,093 additions and 8,514 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
# Daily checks for npm package updates in frontend
# Daily checks for pnpm package updates in frontend
- package-ecosystem: 'npm'
directory: '/'
schedule:
Expand Down
31 changes: 23 additions & 8 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,48 @@ on:

name: ci-build

env:
NODE_VERSION: 20

jobs:

test:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest]
node: [20.18]
pnpm: [9]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout
uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: ${{ matrix.pnpm }}
run_install: false

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'pnpm'

- name: Install dependencies
shell: bash
run: npm ci
run: pnpm install --frozen-lockfile

- name: Check
shell: bash
run: npm run check
run: pnpm run check

- name: Install playwright
shell: bash
run: npx playwright install --with-deps

- name: Test
shell: bash
run: npm test
run: pnpm test

build-container:
runs-on: ubuntu-latest
Expand All @@ -52,4 +67,4 @@ jobs:
registry-username: ${{ github.actor }}
registry-password: ${{ secrets.GITHUB_TOKEN }}
artifact-name: frontend
push-image: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && (github.ref_name == 'master' || github.ref_name == 'develop') }}
push-image: ${{ github.ref_type == 'branch' && github.event_name != 'pull_request' && (github.ref_name == 'master' || github.ref_name == 'develop') }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ node_modules
!.env.example
vite.config.js.timestamp-*
vite.config.ts.timestamp-*
package-lock.json
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.17.0
20.18.0
24 changes: 17 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
FROM node:20-alpine AS build
ARG NODE_VERSION=20
ARG PNPM_VERSION=9.12.2
ARG ALPINE_VERSION=3.20

FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS build

WORKDIR /app
ENV DOCKER=true
ENV PNPM_VERSION=${PNPM_VERSION}

RUN wget -qO /bin/pnpm "https://github.com/pnpm/pnpm/releases/latest/download/pnpm-linuxstatic-x64" && chmod +x /bin/pnpm

COPY package.json .
COPY package-lock.json .
COPY pnpm-lock.yaml .
COPY patches/ patches/

RUN npm ci
RUN pnpm install --frozen-lockfile

COPY . .

RUN npm run build
RUN pnpm run build

FROM node:20-alpine AS runtime
FROM node:${NODE_VERSION}-alpine${ALPINE_VERSION} AS runtime

WORKDIR /app
ENV DOCKER=true
ENV NODE_ENV=production
ENV PNPM_VERSION=${PNPM_VERSION}

RUN wget -qO /bin/pnpm "https://github.com/pnpm/pnpm/releases/latest/download/pnpm-linuxstatic-x64" && chmod +x /bin/pnpm

EXPOSE 3000

COPY --from=build /app/package.json .
COPY --from=build /app/package-lock.json .
COPY --from=build /app/pnpm-lock.yaml .
COPY --from=build /app/patches/ patches/
COPY --from=build /app/build build/

RUN npm ci
RUN pnpm install --frozen-lockfile

CMD ["node","build/index.js"]
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ This is the frontend for the OpenShock project that interfaces with the OpenShoc

## Available Commands

- `npm i` - Install dependencies
- `npm run dev` - Start the development server
- `npm run build` - Build the project
- `npm run preview` - Preview the built project
- `npx openapi-generator-cli generate` - Generate the API client
- `pnpm i` - Install dependencies
- `pnpm run dev` - Start the development server
- `pnpm run build` - Build the project
- `pnpm run preview` - Preview the built project
- `pnpx openapi-generator-cli generate` - Generate the API client

## Setup

To get started with development, you will need to have **Node.js** and **npm** installed.
To get started with development, you will need to have **Node.js** and **pnpm** installed.

We recommend using a version manager like [Volta](https://docs.volta.sh/guide/getting-started) to manage your Node.js versions.

### Install Node.js and npm
### Install Node.js and pnpm

Install on Linux:
```bash
Expand All @@ -49,25 +49,26 @@ Install on Windows:
winget install Volta.Volta
```

Then you can install the required **Node.js** and **npm** version by running a single command in the repository root directory:
Then you can install the required **Node.js** and **pnpm** version by running a single command in the repository root directory:
```bash
volta install
volta install node
volta install pnpm
```

### Install dependencies and build project

With Node.js installed, you can run the following commands to get started:

```bash
npm i
npm run build
pnpm i
pnpm run build
```

## Running locally

Running the frontend locally is as simple as this:
```bash
npm run dev
pnpm run dev
```

### Hosts redirect
Expand Down
Loading

0 comments on commit 1980b74

Please sign in to comment.