-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: docker image for proxy-container
- Loading branch information
Showing
3 changed files
with
59 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |