feat: push-based CD via bastion (build image, scp, compose up)
Runner builds the FE image, transfers image tarball + compose over SSH bastion, prod only docker loads and ups. No repo read access needed on prod.
This commit is contained in:
parent
5e9b2a566d
commit
43c1827fbd
3 changed files with 150 additions and 0 deletions
40
Dockerfile
Normal file
40
Dockerfile
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
# ---- stage 1: build FE ----
|
||||
FROM node:22-alpine AS build
|
||||
WORKDIR /app
|
||||
|
||||
# Biến môi trường Vite (đọc từ .env trên prod lúc compose build).
|
||||
# Đổi API URL -> build lại là nhận (compose up --build tự làm).
|
||||
ARG VITE_API_URL=http://localhost:8000/api/v1
|
||||
ARG VITE_APP_NAME=danable
|
||||
ARG VITE_USE_MOCK_DATA=true
|
||||
ENV VITE_API_URL=$VITE_API_URL \
|
||||
VITE_APP_NAME=$VITE_APP_NAME \
|
||||
VITE_USE_MOCK_DATA=$VITE_USE_MOCK_DATA
|
||||
|
||||
COPY package.json package-lock.json ./
|
||||
RUN npm ci
|
||||
COPY index.html vite.config.ts tsconfig.json tailwind.config.js postcss.config.js ./
|
||||
COPY public ./public
|
||||
COPY src ./src
|
||||
RUN npm run build
|
||||
|
||||
# ---- stage 2: serve tĩnh bằng nginx ----
|
||||
FROM nginx:alpine
|
||||
COPY --from=build /app/dist /usr/share/nginx/html
|
||||
# Ghi đè default conf: SPA fallback + cache lâu cho /assets.
|
||||
# ($$ trong Dockerfile -> $ trong file config.)
|
||||
RUN printf '%s\n' \
|
||||
'server {' \
|
||||
' listen 80;' \
|
||||
' server_name _;' \
|
||||
' root /usr/share/nginx/html;' \
|
||||
' index index.html;' \
|
||||
' location / {' \
|
||||
' try_files $uri $uri/ /index.html;' \
|
||||
' }' \
|
||||
' location /assets/ {' \
|
||||
' expires 30d;' \
|
||||
' add_header Cache-Control "public, immutable";' \
|
||||
' }' \
|
||||
'}' > /etc/nginx/conf.d/default.conf
|
||||
EXPOSE 80
|
||||
Loading…
Add table
Add a link
Reference in a new issue