Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate to pnpm #15

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ concurrency:
group: "build-${{ github.ref }}"
cancel-in-progress: true

env:
DOKKU_HOST: ssh://[email protected]:22
DOKKU_APP: staging-ab-api

jobs:
# Build job
build:
Expand All @@ -37,6 +33,10 @@ jobs:
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/pnpm-lock.yaml" ]; then
echo "manager=pnpm" >> $GITHUB_OUTPUT
echo "command=install --frozen-lockfile" >> $GITHUB_OUTPUT
echo "runner=pnpm" >> $GITHUB_OUTPUT
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
Expand All @@ -46,10 +46,16 @@ jobs:
echo "Unable to determine packager manager"
exit 1
fi
- name: Setup pnpm
if: steps.detect-package-manager.outputs.manager == 'pnpm'
uses: pnpm/action-setup@v2
with:
version: 9
run_install: false
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: "16"
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
40 changes: 18 additions & 22 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
FROM node:16-alpine as development
FROM node:20-alpine AS base

# Create app directory
WORKDIR /usr/src/app
ENV HUSKY=0
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN corepack enable

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY package*.json ./

RUN npm install

# Bundle app source
COPY . .

RUN npm run build

FROM node:16-alpine as production
WORKDIR /usr/src/app

COPY package*.json ./
RUN npm install --only=production
FROM base AS build
WORKDIR /app
COPY .npmrc pnpm-lock.yaml package.json ./
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc pnpm install --frozen-lockfile
COPY . .
RUN pnpm build

COPY --from=development /usr/src/app/dist ./dist
FROM base AS prod
WORKDIR /app
ENV NODE_ENV=production
COPY .npmrc pnpm-lock.yaml package.json Procfile nest-cli.json ./
RUN --mount=type=secret,id=npmrc,target=/root/.npmrc pnpm install --frozen-lockfile --prod
COPY --from=build /app/dist ./dist

CMD [ "npm", "run" , "start:prod" ]
EXPOSE 3000
CMD ["pnpm", "start:prod"]
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ Please go through [Nest Docs](https://docs.nestjs.com/) before playing with the
To run the application you need to have **PostgreSQL** installed.

```bash
$ npm install
$ pnpm install
```

### Running the app

```bash
# development
$ npm run start
$ pnpm run start

# watch mode
$ npm run start:dev

# debug mode
$ npm run start:debug
$ pnpm run start:debug

# production mode
$ npm run start:prod
$ pnpm run start:prod
```

### Running the app with docker :whale:
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ services:
api:
build:
context: .
target: development
target: build
environment:
- DATABASE_URL=postgres://admin:admin@db/wavezync
- DATABASE_URL=postgres://postgres:postgres@db/wavezync
- PORT=3000
ports:
- 3000:3000
Expand Down
Loading
Loading