Initial commit

This commit is contained in:
cedrictech-internal
2026-03-26 13:21:38 +08:00
commit fb770a593d
6 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
name: Deploy PRJ-001 Demo
on:
push:
branches:
- main
jobs:
deploy:
runs-on: deploy-host
steps:
- name: Update repo on server
run: |
set -e
PROJECT_DIR=/srv/projects/PRJ-001
REPO_DIR=$PROJECT_DIR/repo
REMOTE_URL=ssh://git@git.cedrictech.cn:2222/client-projects/prj-001-demo.git
mkdir -p "$PROJECT_DIR"
if [ ! -d "$REPO_DIR/.git" ]; then
git clone "$REMOTE_URL" "$REPO_DIR"
fi
cd "$REPO_DIR"
git fetch origin
git reset --hard origin/main
- name: Run deploy script
run: |
cd /srv/projects/PRJ-001/repo
bash deploy/deploy.sh

2
Dockerfile Normal file
View File

@@ -0,0 +1,2 @@
FROM nginx:alpine
COPY index.html /usr/share/nginx/html/index.html

27
deploy/deploy.sh Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
set -euo pipefail
PROJECT_CODE="PRJ-001"
BASE_DIR="/srv/projects/${PROJECT_CODE}"
REPO_DIR="${BASE_DIR}/repo"
NGINX_LOC_DIR="/etc/nginx/project_locations.d"
NGINX_TARGET="${NGINX_LOC_DIR}/${PROJECT_CODE}.conf"
echo "==> Deploy ${PROJECT_CODE}"
mkdir -p "${BASE_DIR}"
mkdir -p "${NGINX_LOC_DIR}"
cd "${REPO_DIR}"
echo "==> Build and start containers"
docker compose -f deploy/docker-compose.yml up -d --build
echo "==> Install nginx route"
cp deploy/nginx.location.conf "${NGINX_TARGET}"
echo "==> Test and reload nginx"
nginx -t
systemctl reload nginx
echo "==> Done"

10
deploy/docker-compose.yml Normal file
View File

@@ -0,0 +1,10 @@
services:
web:
image: prj-001-demo:latest
build:
context: ..
dockerfile: Dockerfile
container_name: prj-001-demo-web
restart: always
ports:
- "21001:80"

View File

@@ -0,0 +1,7 @@
location /p/PRJ-001/ {
proxy_pass http://127.0.0.1:21001/;
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;
}

12
index.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>PRJ-001 Demo</title>
</head>
<body>
<h1>Hello from PRJ-001</h1>
<p>Deployed by Gitea Actions.</p>
<p>finally!!!</p>
</body>
</html>