Skip to content

Commit 47b11ff

Browse files
Support for private registry NPM packages by using NPM_TOKEN and .npmrc
1 parent 1c80a74 commit 47b11ff

File tree

6 files changed

+17521
-14316
lines changed

6 files changed

+17521
-14316
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ jobs:
4242

4343
- name: 📥 Download deps
4444
run: pnpm install --frozen-lockfile
45+
env:
46+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # Use the NPM_TOKEN here
4547

4648
- name: 📀 Generate Prisma Client
4749
run: pnpm run generate

.npmrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
12
link-workspace-packages=false
2-
public-hoist-pattern[]=*prisma*
3+
public-hoist-pattern[]=*prisma*

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v20.11.1
1+
v20.11.1

docker/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ RUN find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
1010
FROM node:20.11.1-bullseye-slim@sha256:5a5a92b3a8d392691c983719dbdc65d9f30085d6dcd65376e7a32e6fe9bf4cbe AS base
1111
RUN apt-get update && apt-get install -y openssl dumb-init
1212
WORKDIR /triggerdotdev
13+
14+
# Copy .npmrc and use the NPM_TOKEN for private registry
15+
ARG NPM_TOKEN
16+
COPY .npmrc .npmrc
17+
RUN if [ -f .npmrc ]; then \
18+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc; \
19+
fi
1320
COPY --chown=node:node .gitignore .gitignore
1421
COPY --from=pruner --chown=node:node /triggerdotdev/out/json/ .
1522
COPY --from=pruner --chown=node:node /triggerdotdev/out/pnpm-lock.yaml ./pnpm-lock.yaml
@@ -21,6 +28,8 @@ WORKDIR /triggerdotdev
2128
# Corepack is used to install pnpm
2229
RUN corepack enable
2330
ENV NODE_ENV development
31+
# Copy .npmrc again for dev-deps stage
32+
COPY .npmrc .npmrc
2433
RUN pnpm install --ignore-scripts --no-frozen-lockfile
2534

2635
## Production deps
@@ -29,6 +38,8 @@ WORKDIR /triggerdotdev
2938
# Corepack is used to install pnpm
3039
RUN corepack enable
3140
ENV NODE_ENV production
41+
# Copy .npmrc again for production-deps stage
42+
COPY .npmrc .npmrc
3243
RUN pnpm install --prod --no-frozen-lockfile
3344
COPY --from=pruner --chown=node:node /triggerdotdev/internal-packages/database/prisma/schema.prisma /triggerdotdev/internal-packages/database/prisma/schema.prisma
3445
# RUN pnpm add @prisma/[email protected] -w

docker/scripts/build-extension.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Copy the .npmrc file into the build directory
4+
echo "Copying .npmrc to build context..."
5+
cp .npmrc /app/.npmrc
6+
7+
# Set the NPM_TOKEN environment variable for the build
8+
export NPM_TOKEN=$1
9+
10+
# Run the npm install command
11+
echo "Running npm install with NPM_TOKEN..."
12+
pnpm install

0 commit comments

Comments
 (0)