Skip to content

Commit

Permalink
refactor: docker image for proxy-container
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Nov 26, 2022
1 parent f012053 commit 9922151
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 15 deletions.
24 changes: 21 additions & 3 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,37 @@ dist/
# Miscellaneous
.tmp/
.vscode/*
!.vscode/extensions.json
!.vscode/settings.json
.idea/
.DS_Store
.turbo
tsconfig.tsbuildinfo
coverage/
__tests__/

# yarn
.pnp.*
.yarn/*
!.yarn/cache
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.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/
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ dist/
.turbo
tsconfig.tsbuildinfo
coverage/
out/

# yarn
.pnp.*
Expand All @@ -39,4 +40,4 @@ coverage/

# Cache
.prettiercache
.eslintcache
.eslintcache
47 changes: 36 additions & 11 deletions packages/proxy-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -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

COPY . .
RUN yarn dlx turbo prune --scope=@discordjs/proxy-container --docker

FROM node:16-alpine AS installer

RUN apk update
RUN apk add --no-cache libc6-compat

WORKDIR /usr/proxy

# First copy over dependencies separate from src for better caching
COPY package.json yarn.lock tsconfig.json .yarnrc.yml tsup.config.js ./
COPY .yarn ./.yarn
COPY ./packages/proxy-container/package.json ./packages/proxy-container/
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

WORKDIR /usr/proxy/packages/proxy-container
FROM node:16-alpine AS runner

WORKDIR /usr/proxy

RUN yarn workspaces focus
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 proxy
USER proxy

# Next up, copy over our src and build it, then prune deps for prod
COPY ./packages/proxy-container ./
RUN yarn build && yarn workspaces focus --production
COPY --from=installer /usr/proxy .

CMD ["node", "--enable-source-maps", "./dist/index.js"]
CMD ["node", "--enable-source-maps", "packages/proxy-container/dist/index.js"]

0 comments on commit 9922151

Please sign in to comment.