ken4 commited on
Commit
096dde1
·
verified ·
1 Parent(s): 652e5d4

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +14 -11
Dockerfile CHANGED
@@ -1,33 +1,36 @@
 
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
 
1
+ # ===== BUILD STAGE =====
2
  FROM node:20 AS builder
3
 
4
  WORKDIR /app
5
 
6
+ # Clone private repo
7
  RUN --mount=type=secret,id=GITHUB_REPO,required=true \
8
  git clone $(cat /run/secrets/GITHUB_REPO) /app
9
 
10
+ # Install dependencies untuk root (Express + backend)
11
  RUN npm install
12
 
13
+ # Build Nuxt STATIC
14
  WORKDIR /app/nuxt
15
+ RUN yarn install --ignore-engines
16
+ RUN yarn generate
17
 
18
+ # Kembali ke root workspace
19
  WORKDIR /app
20
 
21
+ # Pastikan folder public ada
22
+ RUN mkdir -p public
23
+
24
+ # Copy hasil build nuxt → /public
25
+ RUN cp -r /app/nuxt/dist/* /app/public/
26
 
27
 
28
+ # ===== RUNTIME STAGE =====
 
 
29
  FROM node:20
30
 
31
  WORKDIR /app
32
 
33
+ # Copy hasil build dari stage builder
34
  COPY --from=builder /app /app
35
 
36
  RUN chown -R node:node /app