build: pnpm (#9806)

This commit is contained in:
Noel
2023-08-27 20:24:03 +02:00
committed by GitHub
parent 8325fa6540
commit e96a8a977f
82 changed files with 24444 additions and 28614 deletions

View File

@@ -1,26 +1,34 @@
FROM node:18-alpine AS builder
FROM node:18-alpine AS base
ENV PNPM_HOME="/pnpm"
ENV PATH="$PNPM_HOME:$PATH"
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /usr/proxy
RUN corepack enable
RUN corepack prepare pnpm@latest --activate
COPY manifests .
COPY . /usr/proxy-container
WORKDIR /usr/proxy-container
RUN npm install --global is-ci husky
FROM base AS builder
RUN yarn install --immutable --inline-builds
RUN rm -rf .yarn/cache
RUN pnpm install --frozen-lockfile --ignore-scripts
RUN pnpm exec turbo run build --filter='@discordjs/proxy-container...'
FROM node:18-alpine AS runner
FROM builder AS pruned
WORKDIR /usr/proxy
RUN pnpm --filter='@discordjs/proxy-container' --prod deploy pruned
FROM node:18-alpine AS proxy
WORKDIR /usr/proxy-container
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 proxy
USER proxy
RUN adduser --system --uid 1001 proxy-container
USER proxy-container
COPY --from=builder /usr/proxy .
COPY packs .
COPY --from=pruned /usr/proxy-container/pruned .
CMD ["node", "--enable-source-maps", "dist/index.js"]

View File

@@ -4,11 +4,11 @@
"version": "1.0.0",
"description": "Lightweight HTTP proxy for Discord's API, brought to you as a container 📦",
"scripts": {
"build": "tsup",
"build": "tsc --noEmit && tsup",
"lint": "prettier --check . && cross-env TIMING=1 eslint --format=pretty src",
"format": "prettier --write . && cross-env TIMING=1 eslint --fix --format=pretty src",
"fmt": "yarn format",
"prepack": "yarn lint && yarn build"
"fmt": "pnpm run format",
"prepack": "pnpm run lint && pnpm run build"
},
"type": "module",
"directories": {
@@ -51,7 +51,7 @@
"devDependencies": {
"@types/node": "18.17.9",
"cross-env": "^7.0.3",
"eslint": "^8.47.0",
"eslint": "^8.48.0",
"eslint-config-neon": "^0.1.56",
"eslint-formatter-pretty": "^5.0.0",
"prettier": "^3.0.2",

View File

@@ -3,6 +3,8 @@ import process from 'node:process';
import { proxyRequests } from '@discordjs/proxy';
import { REST } from '@discordjs/rest';
process.on('SIGINT', () => process.exit(0));
// We want to let upstream handle retrying
const api = new REST({ rejectOnRateLimit: () => true, retries: 0 });
const server = createServer(proxyRequests(api));