added build confs
All checks were successful
Build & Deploy Vite App (Docker Compose) / build-and-deploy (push) Successful in 54s
All checks were successful
Build & Deploy Vite App (Docker Compose) / build-and-deploy (push) Successful in 54s
This commit is contained in:
@@ -1,42 +1,22 @@
|
|||||||
name: Build & Deploy Vite App (Docker)
|
name: Build & Deploy Vite App (Docker Compose)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main # kendi ana branch'ini yaz
|
- main # hangi branch'i takip edeceksen onu yaz
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest # runner'ın default label'ı, act_runner buna sahip olmalı
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Kodu checkout et
|
- name: Kodu checkout et
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# 1) Build'i Docker container içinde çalıştır
|
- name: Docker Compose ile deploy
|
||||||
- name: Docker ile Vite build al
|
|
||||||
run: |
|
run: |
|
||||||
docker run --rm \
|
# Eski container'ları kapat
|
||||||
-v $PWD:/app \
|
docker compose down || true
|
||||||
-w /app \
|
|
||||||
node:24 \
|
|
||||||
/bin/bash -lc "npm install && npm run build"
|
|
||||||
|
|
||||||
# 2) Docker image oluştur
|
# Image'i yeniden build et ve container'ı ayağa kaldır
|
||||||
- name: Docker image build et
|
docker compose up -d --build
|
||||||
run: |
|
|
||||||
docker build -t website-app:latest .
|
|
||||||
|
|
||||||
# 3) Eski container'ı durdur / sil
|
|
||||||
- name: Eski container'ı durdur ve sil
|
|
||||||
run: |
|
|
||||||
docker stop website-app || true
|
|
||||||
docker rm website-app || true
|
|
||||||
|
|
||||||
# 4) Yeni image ile container'ı ayağa kaldır
|
|
||||||
- name: Yeni container'ı başlat
|
|
||||||
run: |
|
|
||||||
docker run -d \
|
|
||||||
--name website-app \
|
|
||||||
-p 3005:80 \
|
|
||||||
website-app:latest
|
|
||||||
|
|||||||
17
Dockerfile
Normal file
17
Dockerfile
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# Stage 1: Build
|
||||||
|
FROM node:24-alpine as build
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
# Stage 2: Production
|
||||||
|
FROM nginx:alpine
|
||||||
|
# Özel nginx ayarını kopyala
|
||||||
|
COPY nginx.conf /etc/nginx/conf.d/default.conf
|
||||||
|
# Build aşamasından çıkan dosyaları Nginx'in servis klasörüne kopyala
|
||||||
|
COPY --from=build /app/dist /usr/share/nginx/html
|
||||||
|
|
||||||
|
EXPOSE 80
|
||||||
|
CMD ["nginx", "-g", "daemon off;"]
|
||||||
7
docker-compose.yml
Normal file
7
docker-compose.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
services:
|
||||||
|
frontend:
|
||||||
|
build: .
|
||||||
|
container_name: react-site
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3005:80" # Dışarıya 3005 portunu açıyoruz, NPM buraya bakacak.
|
||||||
14
nginx.conf
Normal file
14
nginx.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
index index.html index.htm;
|
||||||
|
try_files $uri $uri/ /index.html;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_page 500 502 503 504 /50x.html;
|
||||||
|
location = /50x.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user