Compare commits
16 Commits
a33e470e4d
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
| 3ba6b3a1cd | |||
| ec239279f4 | |||
| e2c36e9c0f | |||
| 30bf8ef79c | |||
| 590d1ea9e9 | |||
| cd0f454c98 | |||
| 54e1e5df5a | |||
| 8e3d951d0d | |||
| d04e5bbffb | |||
| 27273bfee4 | |||
| 2a88649f75 | |||
| e9313158ba | |||
| f3da49a76a | |||
| 747f70865d | |||
| 6bb2afa3b7 | |||
| 59008eb59e |
@@ -1,4 +1,4 @@
|
||||
name: Koori-ERP-Deploy-Demo
|
||||
name: ERP-Deploy-Demo
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -59,14 +59,14 @@ jobs:
|
||||
cd /var/www/star-erp-demo
|
||||
chown -R 1000:1000 .
|
||||
|
||||
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|docker-compose\.yaml)'; then
|
||||
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|compose\.demo\.yaml|docker-compose\.yaml)'; then
|
||||
echo "🔄 偵測到 Docker 相關檔案變更,執行完整重建..."
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose up -d --build --wait
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose -f compose.yaml -f compose.demo.yaml up -d --build --wait
|
||||
else
|
||||
echo "⚡ 無 Docker 檔案變更,僅重載服務..."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q 'star-erp-laravel'; then
|
||||
echo "容器未運行,正在啟動..."
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose up -d --wait
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose -f compose.yaml -f compose.demo.yaml up -d --wait
|
||||
else
|
||||
echo "容器已運行,跳過 docker compose,直接進行程式碼部署..."
|
||||
fi
|
||||
@@ -86,6 +86,7 @@ jobs:
|
||||
composer install --no-dev --optimize-autoloader --no-interaction &&
|
||||
npm install &&
|
||||
npm run build &&
|
||||
rm -f public/hot &&
|
||||
php artisan storage:link &&
|
||||
php artisan migrate --force &&
|
||||
php artisan tenants:migrate --force &&
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Koori-ERP-Deploy-Production
|
||||
name: ERP-Deploy-Production
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -41,9 +41,6 @@ jobs:
|
||||
key: ${{ secrets.PROD_SSH_KEY }}
|
||||
script: |
|
||||
cd /var/www/star-erp
|
||||
# [Patch] 修正正式機 Nginx Proxy 配置 (對應外部 SSL/OpenResty)
|
||||
sed -i "s/- '8080:8080'/- '80:80'\n - '8080:8080'/" compose.yaml
|
||||
sed -i "s/demo-proxy.conf/prod-proxy.conf/" compose.yaml
|
||||
|
||||
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|docker-compose\.yaml)'; then
|
||||
echo "REBUILD_NEEDED=true"
|
||||
@@ -62,14 +59,14 @@ jobs:
|
||||
cd /var/www/star-erp
|
||||
chown -R 1000:1000 .
|
||||
|
||||
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|docker-compose\.yaml)'; then
|
||||
if git diff --name-only HEAD~1 HEAD 2>/dev/null | grep -qE '(Dockerfile|compose\.yaml|compose\.prod\.yaml|docker-compose\.yaml)'; then
|
||||
echo "🔄 偵測到 Docker 相關檔案變更,執行完整重建..."
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose up -d --build --wait
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose -f compose.yaml -f compose.prod.yaml up -d --build --wait
|
||||
else
|
||||
echo "⚡ 無 Docker 檔案變更,僅重載服務..."
|
||||
if ! docker ps --format '{{.Names}}' | grep -q 'star-erp-laravel'; then
|
||||
echo "容器未運行,正在啟動..."
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose up -d --wait
|
||||
WWWGROUP=1000 WWWUSER=1000 docker compose -f compose.yaml -f compose.prod.yaml up -d --wait
|
||||
else
|
||||
echo "容器已運行,跳過 docker compose,直接進行程式碼部署..."
|
||||
fi
|
||||
@@ -80,7 +77,8 @@ jobs:
|
||||
docker exec -u 1000:1000 -w /var/www/html star-erp-laravel sh -c "
|
||||
composer install --no-dev --optimize-autoloader &&
|
||||
npm install &&
|
||||
npm run build
|
||||
npm run build &&
|
||||
rm -f public/hot
|
||||
|
||||
php artisan storage:link &&
|
||||
php artisan migrate --force &&
|
||||
|
||||
7
compose.demo.yaml
Normal file
7
compose.demo.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
proxy:
|
||||
ports:
|
||||
- '80:80'
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
- './nginx/demo-proxy.conf:/etc/nginx/conf.d/default.conf:ro'
|
||||
7
compose.prod.yaml
Normal file
7
compose.prod.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
services:
|
||||
proxy:
|
||||
ports:
|
||||
- '80:80'
|
||||
- '8080:8080'
|
||||
volumes:
|
||||
- './nginx/prod-proxy.conf:/etc/nginx/conf.d/default.conf:ro'
|
||||
17
compose.yaml
17
compose.yaml
@@ -6,8 +6,8 @@ services:
|
||||
args:
|
||||
WWWGROUP: '${WWWGROUP}'
|
||||
image: 'sail-8.5/app'
|
||||
container_name: star-erp-laravel
|
||||
hostname: star-erp-laravel
|
||||
container_name: laravel
|
||||
hostname: laravel
|
||||
extra_hosts:
|
||||
- 'host.docker.internal:host-gateway'
|
||||
ports:
|
||||
@@ -29,8 +29,8 @@ services:
|
||||
# - mailpit
|
||||
mysql:
|
||||
image: 'mysql/mysql-server:8.0'
|
||||
container_name: star-erp-mysql
|
||||
hostname: star-erp-mysql
|
||||
container_name: mysql
|
||||
hostname: mysql
|
||||
ports:
|
||||
- '${FORWARD_DB_PORT:-3306}:3306'
|
||||
environment:
|
||||
@@ -56,8 +56,8 @@ services:
|
||||
timeout: 5s
|
||||
redis:
|
||||
image: 'redis:alpine'
|
||||
container_name: star-erp-redis
|
||||
hostname: star-erp-redis
|
||||
container_name: redis
|
||||
hostname: redis
|
||||
# ports:
|
||||
# - '${FORWARD_REDIS_PORT:-6379}:6379'
|
||||
volumes:
|
||||
@@ -74,11 +74,6 @@ services:
|
||||
proxy:
|
||||
image: 'nginx:alpine'
|
||||
container_name: star-erp-proxy
|
||||
ports:
|
||||
- '8080:8080'
|
||||
- '8081:8081'
|
||||
volumes:
|
||||
- './nginx/demo-proxy.conf:/etc/nginx/conf.d/default.conf:ro'
|
||||
networks:
|
||||
- sail
|
||||
depends_on:
|
||||
|
||||
@@ -11,7 +11,7 @@ WORKDIR /var/www/html
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
ENV TZ=UTC
|
||||
ENV SUPERVISOR_PHP_COMMAND="/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=80"
|
||||
ENV SUPERVISOR_PHP_COMMAND="/usr/bin/php -d variables_order=EGPCS /var/www/html/artisan serve --host=0.0.0.0 --port=8080"
|
||||
ENV SUPERVISOR_PHP_USER="sail"
|
||||
ENV PLAYWRIGHT_BROWSERS_PATH=0
|
||||
|
||||
@@ -75,8 +75,6 @@ RUN apt-get update && apt-get upgrade -y \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.5
|
||||
|
||||
RUN userdel -r ubuntu
|
||||
RUN groupadd --force -g $WWWGROUP sail
|
||||
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 sail
|
||||
@@ -87,6 +85,6 @@ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
COPY php.ini /etc/php/8.5/cli/conf.d/99-sail.ini
|
||||
RUN chmod +x /usr/local/bin/start-container
|
||||
|
||||
EXPOSE 80/tcp
|
||||
EXPOSE 8080/tcp
|
||||
|
||||
ENTRYPOINT ["start-container"]
|
||||
|
||||
@@ -1,29 +1,22 @@
|
||||
# 總後台 (landlord) - 端口 8080
|
||||
server {
|
||||
listen 8080;
|
||||
server_name _;
|
||||
# Demo 環境 (Demo) - 端口 80
|
||||
# 外部 SSL 終止後(如 Cloudflare/NPM)轉發至此端口
|
||||
|
||||
location / {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_set_header Host star-erp.demo;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||
}
|
||||
# 定義 map 以正確處理 X-Forwarded-Proto
|
||||
map $http_x_forwarded_proto $proxy_x_forwarded_proto {
|
||||
default $http_x_forwarded_proto;
|
||||
'' $scheme;
|
||||
}
|
||||
|
||||
# koori 租戶 - 端口 8081
|
||||
server {
|
||||
listen 8081;
|
||||
server_name _;
|
||||
listen 80;
|
||||
server_name demo-erp.taiwan-star.com.tw;
|
||||
|
||||
location / {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_pass http://star-erp-laravel:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header X-Forwarded-Host $host:$server_port;
|
||||
proxy_set_header X-Forwarded-Proto $proxy_x_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ server {
|
||||
server_name erp.koori.tw erp.mamaiclub.com;
|
||||
|
||||
location / {
|
||||
proxy_pass http://star-erp-laravel:80;
|
||||
proxy_pass http://star-erp-laravel:8080;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
|
||||
Reference in New Issue
Block a user