Initial commit
This commit is contained in:
34
.gitea/workflows/deploy.yml
Normal file
34
.gitea/workflows/deploy.yml
Normal 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
2
Dockerfile
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
COPY index.html /usr/share/nginx/html/index.html
|
||||||
27
deploy/deploy.sh
Executable file
27
deploy/deploy.sh
Executable 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
10
deploy/docker-compose.yml
Normal 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"
|
||||||
7
deploy/nginx.location.conf
Normal file
7
deploy/nginx.location.conf
Normal 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
12
index.html
Normal 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>
|
||||||
Reference in New Issue
Block a user