Skip to content

Commit

Permalink
chore: Monorepo @megabrain/club Docker Build & Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ByungJin-Lee committed May 15, 2023
1 parent 332099b commit ac82540
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 176 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
26 changes: 18 additions & 8 deletions dockerFiles/club.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
FROM node:18-alpine AS base

FROM base AS deps
WORKDIR /usr/src/app

COPY package.json yarn.lock .yarnrc.yml ./
COPY .yarn ./.yarn
COPY packages ./packages
COPY apps/club ./apps/club

RUN yarn install;
RUN rm -rf /usr/src/app/apps/club/.next/cache

# Rebuild the source code only when needed
FROM base AS builder
WORKDIR /usr/src/app
COPY . .
RUN yarn install
COPY --from=deps /usr/src/app .
COPY .eslintrc.js .prettierrc .
RUN yarn build:club

# Production image, copy all the files and run next
FROM base AS runner
WORKDIR /usr/src/app

ENV NODE_ENV=production

RUN yarn global add pm2

COPY --from=builder /usr/src/app/apps/club/public ./public
COPY --from=builder /usr/src/app/apps/club/.next/standalone/apps/club ./
COPY --from=builder /usr/src/app/apps/club/.next/static ./.next/static
COPY --from=builder /usr/src/app/apps/club/.next/standalone ./
COPY --from=builder /usr/src/app/apps/club/.next/static ./apps/club/.next/static

EXPOSE 3000

ENV PORT 300
# ENV PORT 3000

Entrypoint ["pm2", "start", "server.js", "--name", "megabrain-club"];
ENTRYPOINT ["pm2-runtime", "start", "./apps/club/server.js", "--env", "production"];
10 changes: 10 additions & 0 deletions dockerFiles/club.Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**/.github
**/.husky
**/.idea
**/.vscode
**/.gitignore
**/README.md
**/node_modules
**/.next
apps
!apps/club
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"author": "Megabrain",
"license": "MIT",
"devDependencies": {
"@esbuild/linux-arm64": "0.17.18",
"@megabrain/eslint-config": "workspace:^",
"@next/swc-linux-arm64-musl": "13.4.1",
"@types/eslint": "^8.37.0",
"@types/node": "^20.1.2",
"@types/prettier": "^2",
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
"dependencies": {
"@stitches/react": "^1.2.8",
"next": "^13.4.1",
"next": "13.4.1",
"react-feather": "^2.0.10"
},
"scripts": {
Expand Down
175 changes: 8 additions & 167 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1561,6 +1561,7 @@ __metadata:
"@esbuild/linux-arm64@npm:0.17.18":
version: 0.17.18
resolution: "@esbuild/linux-arm64@npm:0.17.18"
checksum: 8076537841205a9dfdd8434204ef58ec057bfd78143d4ebf8aa99204474b9785b1e6de285ce0728b309639c5fcd1182755c8cae65aa49298436f67eb2ebbf3d9
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
Expand Down Expand Up @@ -1913,8 +1914,8 @@ __metadata:
"@types/react": 18.2.6
"@types/react-dom": 18.2.4
eslint: 8.40.0
eslint-config-next: 13.4.2
next: 13.4.2
eslint-config-next: 13.4.1
next: 13.4.1
react: 18.2.0
react-dom: 18.2.0
tsconfig: "workspace:^"
Expand Down Expand Up @@ -1997,7 +1998,7 @@ __metadata:
"@types/react": ^18.2.6
"@types/react-dom": ^18.2.4
eslint: ^8.40.0
next: ^13.4.1
next: 13.4.1
react: ^18.2.0
react-dom: ^18.2.0
react-feather: ^2.0.10
Expand Down Expand Up @@ -2025,13 +2026,6 @@ __metadata:
languageName: node
linkType: hard

"@next/env@npm:13.4.2":
version: 13.4.2
resolution: "@next/env@npm:13.4.2"
checksum: 103f0e836c16f69067410d780a411668c640b93cb380ba5a13a5d014f5e83bc9b4745c8840e319aebffc31b3cddeb9804e96ccca1411a11de0de6056c3d99f0a
languageName: node
linkType: hard

"@next/eslint-plugin-next@npm:13.4.1":
version: 13.4.1
resolution: "@next/eslint-plugin-next@npm:13.4.1"
Expand All @@ -2041,67 +2035,31 @@ __metadata:
languageName: node
linkType: hard

"@next/eslint-plugin-next@npm:13.4.2":
version: 13.4.2
resolution: "@next/eslint-plugin-next@npm:13.4.2"
dependencies:
glob: 7.1.7
checksum: be6d258eedeb52c120796076b0243d3b2f051e84b43990a4a61ab2e26e143982641e97c71ad7c657e9bb1054a7fe12eebb91e4b76dfc99953c859eff01ee9c89
languageName: node
linkType: hard

"@next/swc-darwin-arm64@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-darwin-arm64@npm:13.4.1"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@next/swc-darwin-arm64@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-darwin-arm64@npm:13.4.2"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@next/swc-darwin-x64@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-darwin-x64@npm:13.4.1"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@next/swc-darwin-x64@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-darwin-x64@npm:13.4.2"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@next/swc-linux-arm64-gnu@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-linux-arm64-gnu@npm:13.4.1"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@next/swc-linux-arm64-gnu@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-linux-arm64-gnu@npm:13.4.2"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@next/swc-linux-arm64-musl@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-linux-arm64-musl@npm:13.4.1"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@next/swc-linux-arm64-musl@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-linux-arm64-musl@npm:13.4.2"
checksum: 442178a543e2a417ce37f9eade58426f14c420fecd579b49a676cd89a5b047d97c6d47ea9b4490680e04f001706ed031afd3d97384a2a650dd187a2ab69f3f26
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard
Expand All @@ -2113,69 +2071,34 @@ __metadata:
languageName: node
linkType: hard

"@next/swc-linux-x64-gnu@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-linux-x64-gnu@npm:13.4.2"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@next/swc-linux-x64-musl@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-linux-x64-musl@npm:13.4.1"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@next/swc-linux-x64-musl@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-linux-x64-musl@npm:13.4.2"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@next/swc-win32-arm64-msvc@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-win32-arm64-msvc@npm:13.4.1"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@next/swc-win32-arm64-msvc@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-win32-arm64-msvc@npm:13.4.2"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard

"@next/swc-win32-ia32-msvc@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-win32-ia32-msvc@npm:13.4.1"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@next/swc-win32-ia32-msvc@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-win32-ia32-msvc@npm:13.4.2"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@next/swc-win32-x64-msvc@npm:13.4.1":
version: 13.4.1
resolution: "@next/swc-win32-x64-msvc@npm:13.4.1"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"@next/swc-win32-x64-msvc@npm:13.4.2":
version: 13.4.2
resolution: "@next/swc-win32-x64-msvc@npm:13.4.2"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"@nodelib/fs.scandir@npm:2.1.5":
version: 2.1.5
resolution: "@nodelib/fs.scandir@npm:2.1.5"
Expand Down Expand Up @@ -6326,29 +6249,6 @@ __metadata:
languageName: node
linkType: hard

"eslint-config-next@npm:13.4.2":
version: 13.4.2
resolution: "eslint-config-next@npm:13.4.2"
dependencies:
"@next/eslint-plugin-next": 13.4.2
"@rushstack/eslint-patch": ^1.1.3
"@typescript-eslint/parser": ^5.42.0
eslint-import-resolver-node: ^0.3.6
eslint-import-resolver-typescript: ^3.5.2
eslint-plugin-import: ^2.26.0
eslint-plugin-jsx-a11y: ^6.5.1
eslint-plugin-react: ^7.31.7
eslint-plugin-react-hooks: ^4.5.0
peerDependencies:
eslint: ^7.23.0 || ^8.0.0
typescript: ">=3.3.1"
peerDependenciesMeta:
typescript:
optional: true
checksum: 7967443d493a0b0fc45629c587c642f3aef4e17968592b4aea53bc858dc61091a98786aeae2d6d6d574434b838a0935d3d3d20246bd914880bf9a4b82caf7cf8
languageName: node
linkType: hard

"eslint-config-prettier@npm:^8.8.0":
version: 8.8.0
resolution: "eslint-config-prettier@npm:8.8.0"
Expand Down Expand Up @@ -8892,7 +8792,9 @@ __metadata:
version: 0.0.0-use.local
resolution: "megabrain-apps@workspace:."
dependencies:
"@esbuild/linux-arm64": 0.17.18
"@megabrain/eslint-config": "workspace:^"
"@next/swc-linux-arm64-musl": 13.4.1
"@types/eslint": ^8.37.0
"@types/node": ^20.1.2
"@types/prettier": ^2
Expand Down Expand Up @@ -9220,7 +9122,7 @@ __metadata:
languageName: node
linkType: hard

"next@npm:13.4.1, next@npm:^13.4.1":
"next@npm:13.4.1":
version: 13.4.1
resolution: "next@npm:13.4.1"
dependencies:
Expand Down Expand Up @@ -9281,67 +9183,6 @@ __metadata:
languageName: node
linkType: hard

"next@npm:13.4.2":
version: 13.4.2
resolution: "next@npm:13.4.2"
dependencies:
"@next/env": 13.4.2
"@next/swc-darwin-arm64": 13.4.2
"@next/swc-darwin-x64": 13.4.2
"@next/swc-linux-arm64-gnu": 13.4.2
"@next/swc-linux-arm64-musl": 13.4.2
"@next/swc-linux-x64-gnu": 13.4.2
"@next/swc-linux-x64-musl": 13.4.2
"@next/swc-win32-arm64-msvc": 13.4.2
"@next/swc-win32-ia32-msvc": 13.4.2
"@next/swc-win32-x64-msvc": 13.4.2
"@swc/helpers": 0.5.1
busboy: 1.6.0
caniuse-lite: ^1.0.30001406
postcss: 8.4.14
styled-jsx: 5.1.1
zod: 3.21.4
peerDependencies:
"@opentelemetry/api": ^1.1.0
fibers: ">= 3.1.0"
node-sass: ^6.0.0 || ^7.0.0
react: ^18.2.0
react-dom: ^18.2.0
sass: ^1.3.0
dependenciesMeta:
"@next/swc-darwin-arm64":
optional: true
"@next/swc-darwin-x64":
optional: true
"@next/swc-linux-arm64-gnu":
optional: true
"@next/swc-linux-arm64-musl":
optional: true
"@next/swc-linux-x64-gnu":
optional: true
"@next/swc-linux-x64-musl":
optional: true
"@next/swc-win32-arm64-msvc":
optional: true
"@next/swc-win32-ia32-msvc":
optional: true
"@next/swc-win32-x64-msvc":
optional: true
peerDependenciesMeta:
"@opentelemetry/api":
optional: true
fibers:
optional: true
node-sass:
optional: true
sass:
optional: true
bin:
next: dist/bin/next
checksum: 73b9da0d72b54720791ec3e3a3c79922172de5df01d5157507bd095033c33cd611f35da3310d859b3a75456977a4a9a4ef311074517b172dddc92dc769e03e49
languageName: node
linkType: hard

"no-case@npm:^3.0.4":
version: 3.0.4
resolution: "no-case@npm:3.0.4"
Expand Down

0 comments on commit ac82540

Please sign in to comment.