refactor: docker image for proxy-container

This commit is contained in:
iCrawl
2022-11-26 02:09:05 +01:00
parent f0120538bb
commit 9922151266
3 changed files with 59 additions and 15 deletions

View File

@@ -20,19 +20,37 @@ dist/
# Miscellaneous # Miscellaneous
.tmp/ .tmp/
.vscode/* .vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea/ .idea/
.DS_Store .DS_Store
.turbo .turbo
tsconfig.tsbuildinfo tsconfig.tsbuildinfo
coverage/
__tests__/
# yarn # yarn
.pnp.* .pnp.*
.yarn/* .yarn/*
!.yarn/cache
!.yarn/patches !.yarn/patches
!.yarn/plugins !.yarn/plugins
!.yarn/releases !.yarn/releases
!.yarn/sdks !.yarn/sdks
!.yarn/versions !.yarn/versions
# Cache
.prettiercache
.eslintcache
# Docker specific
.cliff-jumperrc.json
api-extractor.json
.eslintrc.json
.lintstagedrc.cjs
.lintstagedrc.cjs
.prettierignore
.prettierrc.js
.prettierrc.cjs
cliff.toml
CHANGELOG.md
README.md
tsconfig.eslint.json
docs/

1
.gitignore vendored
View File

@@ -27,6 +27,7 @@ dist/
.turbo .turbo
tsconfig.tsbuildinfo tsconfig.tsbuildinfo
coverage/ coverage/
out/
# yarn # yarn
.pnp.* .pnp.*

View File

@@ -1,18 +1,43 @@
FROM node:16-alpine FROM node:16-alpine as builder
RUN apk update
RUN apk add --no-cache libc6-compat
WORKDIR /usr/proxy WORKDIR /usr/proxy
# First copy over dependencies separate from src for better caching COPY . .
COPY package.json yarn.lock tsconfig.json .yarnrc.yml tsup.config.js ./ RUN yarn dlx turbo prune --scope=@discordjs/proxy-container --docker
COPY .yarn ./.yarn
COPY ./packages/proxy-container/package.json ./packages/proxy-container/
WORKDIR /usr/proxy/packages/proxy-container FROM node:16-alpine AS installer
RUN yarn workspaces focus RUN apk update
RUN apk add --no-cache libc6-compat
# Next up, copy over our src and build it, then prune deps for prod WORKDIR /usr/proxy
COPY ./packages/proxy-container ./
RUN yarn build && yarn workspaces focus --production
CMD ["node", "--enable-source-maps", "./dist/index.js"] COPY .gitignore .gitignore
COPY .yarn/ .yarn/
COPY .yarnrc.yml .yarnrc.yml
COPY --from=builder /usr/proxy/out/json/ .
COPY --from=builder /usr/proxy/out/yarn.lock ./yarn.lock
RUN yarn install
COPY --from=builder /usr/proxy/out/full/ .
COPY tsup.config.js tsup.config.js
COPY turbo.json turbo.json
COPY tsconfig.json tsconfig.json
RUN yarn dlx turbo run build --filter=@discordjs/proxy-container...
RUN yarn workspaces focus @discordjs/proxy-container --production
FROM node:16-alpine AS runner
WORKDIR /usr/proxy
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 proxy
USER proxy
COPY --from=installer /usr/proxy .
CMD ["node", "--enable-source-maps", "packages/proxy-container/dist/index.js"]