ken4 commited on
Commit
652e5d4
·
verified ·
1 Parent(s): 5ec2813

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +25 -11
Dockerfile CHANGED
@@ -1,24 +1,38 @@
1
- FROM node:20
2
-
3
- ARG CACHEBUST=1
4
 
5
  WORKDIR /app
6
 
7
- # Clone repo privat
8
  RUN --mount=type=secret,id=GITHUB_REPO,required=true \
9
  git clone $(cat /run/secrets/GITHUB_REPO) /app
10
 
11
- # Enable yarn (Corepack)
12
- RUN corepack enable
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- # Install & build
15
- RUN yarn install
16
- RUN yarn build
17
 
18
- # Perizinan
19
  RUN chown -R node:node /app
20
  USER node
21
 
22
  EXPOSE 7860
23
 
24
- CMD ["yarn", "start"]
 
1
+ FROM node:20 AS builder
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # clone repo
6
  RUN --mount=type=secret,id=GITHUB_REPO,required=true \
7
  git clone $(cat /run/secrets/GITHUB_REPO) /app
8
 
9
+ # install deps untuk EXPRESS
10
+ RUN npm install
11
+
12
+ # build NUXT di folder /nuxt
13
+ WORKDIR /app/nuxt
14
+ RUN npm install
15
+ RUN npm run build
16
+
17
+ # balik ke root
18
+ WORKDIR /app
19
+
20
+ # pindahkan hasil build Nuxt ke public agar bisa di-serve Express
21
+ RUN cp -r /app/nuxt/.output/public ./public
22
+
23
+
24
+ # ==============================
25
+ # RUNTIME
26
+ # ==============================
27
+ FROM node:20
28
+
29
+ WORKDIR /app
30
 
31
+ COPY --from=builder /app /app
 
 
32
 
 
33
  RUN chown -R node:node /app
34
  USER node
35
 
36
  EXPOSE 7860
37
 
38
+ CMD ["npm", "start"]