🔧 Migrate from npm to Bun (#2097)
This commit is contained in:
@@ -1,23 +1,26 @@
|
||||
# Stage 0, "build-stage", based on Node.js, to build and compile the frontend
|
||||
FROM node:24 AS build-stage
|
||||
# Stage 0, "build-stage", based on Bun, to build and compile the frontend
|
||||
FROM oven/bun:1 AS build-stage
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json /app/
|
||||
COPY package.json bun.lock /app/
|
||||
|
||||
RUN npm install
|
||||
COPY frontend/package.json /app/frontend/
|
||||
|
||||
COPY ./ /app/
|
||||
WORKDIR /app/frontend
|
||||
|
||||
ARG VITE_API_URL=${VITE_API_URL}
|
||||
RUN bun install
|
||||
|
||||
RUN npm run build
|
||||
COPY ./frontend /app/frontend
|
||||
ARG VITE_API_URL
|
||||
|
||||
RUN bun run build
|
||||
|
||||
|
||||
# Stage 1, based on Nginx, to have only the compiled app, ready for production with Nginx
|
||||
FROM nginx:1
|
||||
|
||||
COPY --from=build-stage /app/dist/ /usr/share/nginx/html
|
||||
COPY --from=build-stage /app/frontend/dist/ /usr/share/nginx/html
|
||||
|
||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf
|
||||
COPY ./frontend/nginx.conf /etc/nginx/conf.d/default.conf
|
||||
COPY ./frontend/nginx-backend-not-found.conf /etc/nginx/extra-conf.d/backend-not-found.conf
|
||||
|
||||
@@ -2,10 +2,20 @@ FROM mcr.microsoft.com/playwright:v1.57.0-noble
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
COPY package*.json /app/
|
||||
RUN apt-get update && apt-get install -y unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN npm install
|
||||
RUN curl -fsSL https://bun.sh/install | bash
|
||||
ENV PATH="/root/.bun/bin:$PATH"
|
||||
|
||||
COPY ./ /app/
|
||||
COPY package.json bun.lock /app/
|
||||
|
||||
ARG VITE_API_URL=${VITE_API_URL}
|
||||
COPY frontend/package.json /app/frontend/
|
||||
|
||||
WORKDIR /app/frontend
|
||||
|
||||
RUN bun install
|
||||
|
||||
COPY ./frontend /app/frontend
|
||||
|
||||
ARG VITE_API_URL
|
||||
|
||||
@@ -2,42 +2,15 @@
|
||||
|
||||
The frontend is built with [Vite](https://vitejs.dev/), [React](https://reactjs.org/), [TypeScript](https://www.typescriptlang.org/), [TanStack Query](https://tanstack.com/query), [TanStack Router](https://tanstack.com/router) and [Tailwind CSS](https://tailwindcss.com/).
|
||||
|
||||
## Frontend development
|
||||
## Requirements
|
||||
|
||||
Before you begin, ensure that you have either the Node Version Manager (nvm) or Fast Node Manager (fnm) installed on your system.
|
||||
- [Bun](https://bun.sh/) (recommended) or [Node.js](https://nodejs.org/)
|
||||
|
||||
* To install fnm follow the [official fnm guide](https://github.com/Schniz/fnm#installation). If you prefer nvm, you can install it using the [official nvm guide](https://github.com/nvm-sh/nvm#installing-and-updating).
|
||||
|
||||
* After installing either nvm or fnm, proceed to the `frontend` directory:
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
# If using fnm
|
||||
fnm install
|
||||
|
||||
# If using nvm
|
||||
nvm install
|
||||
```
|
||||
|
||||
* Once the installation is complete, switch to the installed version:
|
||||
|
||||
```bash
|
||||
# If using fnm
|
||||
fnm use
|
||||
|
||||
# If using nvm
|
||||
nvm use
|
||||
```
|
||||
|
||||
* Within the `frontend` directory, install the necessary NPM packages:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
* And start the live server with the following `npm` script:
|
||||
|
||||
```bash
|
||||
npm run dev
|
||||
bun install
|
||||
bun run dev
|
||||
```
|
||||
|
||||
* Then open your browser at http://localhost:5173/.
|
||||
@@ -89,7 +62,7 @@ But it would be only to clean them up, leaving them won't really have any effect
|
||||
* To generate the frontend client, run:
|
||||
|
||||
```bash
|
||||
npm run generate-client
|
||||
bun run generate-client
|
||||
```
|
||||
|
||||
* Commit the changes.
|
||||
@@ -128,13 +101,13 @@ docker compose up -d --wait backend
|
||||
Then, you can run the tests with the following command:
|
||||
|
||||
```bash
|
||||
npx playwright test
|
||||
bunx playwright test
|
||||
```
|
||||
|
||||
You can also run your tests in UI mode to see the browser and interact with it running:
|
||||
|
||||
```bash
|
||||
npx playwright test --ui
|
||||
bunx playwright test --ui
|
||||
```
|
||||
|
||||
To stop and remove the Docker Compose stack and clean the data created in tests, use the following command:
|
||||
|
||||
@@ -84,7 +84,7 @@ export default defineConfig({
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: {
|
||||
command: 'npm run dev',
|
||||
command: 'bun run dev',
|
||||
url: 'http://localhost:5173',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user