commit fb770a593d46145afee66d948c4ded48ce20b883 Author: cedrictech-internal <> Date: Thu Mar 26 13:21:38 2026 +0800 Initial commit diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..ade5414 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ef646a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,2 @@ +FROM nginx:alpine +COPY index.html /usr/share/nginx/html/index.html diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100755 index 0000000..d442a56 --- /dev/null +++ b/deploy/deploy.sh @@ -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" diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml new file mode 100644 index 0000000..f336038 --- /dev/null +++ b/deploy/docker-compose.yml @@ -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" diff --git a/deploy/nginx.location.conf b/deploy/nginx.location.conf new file mode 100644 index 0000000..e3b7636 --- /dev/null +++ b/deploy/nginx.location.conf @@ -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; +} diff --git a/index.html b/index.html new file mode 100644 index 0000000..7116f10 --- /dev/null +++ b/index.html @@ -0,0 +1,12 @@ + + +
+ +Deployed by Gitea Actions.
+finally!!!
+ +