moving from cloud run to OVHCloud VPS

This commit is contained in:
itsamejms
2026-06-13 11:23:36 +01:00
parent 6cd6c2a0d8
commit 4950ea2402
8 changed files with 118 additions and 25 deletions
+18
View File
@@ -0,0 +1,18 @@
# Step 1: Grab the official Litestream binary
FROM litestream/litestream:0.3.13 AS litestream
# Step 2: Build our actual runtime container using official Gitea
FROM gitea/gitea:1.22.0
# Copy Litestream binary into the Gitea container
COPY --from=litestream /usr/local/bin/litestream /usr/local/bin/litestream
# Copy our custom configuration files
COPY litestream.yml /etc/litestream.yml
COPY entrypoint.sh /usr/local/bin/litestream-entrypoint.sh
# Make sure our script is executable by the container
RUN chmod +x /usr/local/bin/litestream-entrypoint.sh
# Re-route the container's entrypoint to use our custom script
ENTRYPOINT ["/usr/local/bin/litestream-entrypoint.sh"]
+29
View File
@@ -0,0 +1,29 @@
## GCP deploy
- `gcloud auth login`
- `gcloud config set project itsamejms`
- `gcloud auth application-default set-quota-project itsamejms`
- `gcloud run services list`
- `gcloud services enable run.googleapis.com artifactregistry.googleapis.com storage.googleapis.com`
- `gcloud storage buckets create gs://jms-git-bucket --location=europe-west1` # for snapshots
- `gcloud storage buckets create gs://jms-git-repos-storage --location=europe-west1` # for repositories .git folders
```
gcloud beta run deploy gitea-serverless \
--source . \
--region europe-west1 \
--allow-unauthenticated \
--max-instances 1 \
--memory 1Gi \
--port 3000 \
--set-env-vars="GCS_BUCKET_NAME=jms-git-bucket" \
--set-env-vars="GITEA_WORK_DIR=/data/gitea" \
--set-env-vars="GITEA_CUSTOM=/data/gitea" \
--set-env-vars="GCS_ACCESS_KEY=GCS_ACCESS_KEY" \
--set-env-vars="GCS_SECRET_KEY=GCS_SECRET_KEY" \
--add-volume=name=git-storage,type=cloud-storage,bucket=jms-git-repos-storage,mount-options="uid=1000;gid=1000;file-mode=0666;dir-mode=0777;stat-cache-ttl=600s;type-cache-ttl=600s" \
--add-volume-mount=volume=git-storage,mount-path=/data/gitea/app_data/repositories
```
### Gitea git dump
- `gcloud storage cp -r 'gs://jms-git-repos-storage/*' ./gitea-dump/`
+84
View File
@@ -0,0 +1,84 @@
#!/bin/bash
set -e
# Define standard storage paths inside our writeable volume
DB_PATH="/data/gitea/gitea.db"
CONF_DIR="/data/gitea/conf"
CONF_PATH="$CONF_DIR/app.ini"
# 1. Initialize writeable working directories safely
mkdir -p "$CONF_DIR"
mkdir -p /data/gitea/app_data/repositories # Ensure mount path target exists
# FIX: Only chown local assets. Explicitly avoid running a recursive chown on the GCS FUSE mount!
chown git:git /data /data/gitea /data/gitea/gitea.db /data/gitea/conf 2>/dev/null || true
# 2. Restore SQLite database if it exists in Cloud Storage
if [ ! -f "$DB_PATH" ]; then
echo "[Litestream] SQLite database not found locally. Checking GCS for replica..."
if litestream restore -config /etc/litestream.yml "$DB_PATH"; then
echo "[Litestream] Database successfully restored from GCS."
chown git:git "$DB_PATH"
else
echo "[Litestream] No backup replica found. Initializing new database."
fi
fi
# 3. Launch the Litestream background replication process
echo "[Litestream] Starting replication backend process..."
litestream replicate -config /etc/litestream.yml &
# 4. MANUALLY WRITE THE APP.INI CONFIG FILE (Explicit Block Overrides)
echo "[Gitea] Writing configuration profile to app.ini..."
cat <<EOF > "$CONF_PATH"
APP_NAME = Serverless Git
RUN_MODE = prod
RUN_USER = git
[database]
DB_TYPE = sqlite3
PATH = $DB_PATH
[security]
INSTALL_LOCK = true
[server]
HTTP_PORT = 3000
PROTOCOL = http
DOMAIN = gitea.jms.rocks
ROOT_URL = https://gitea.jms.rocks/
DISABLE_SSH = true
LIMIT_SIZE_REJECT_REQUEST = false
DISABLE_QUERY_STR_CHECK = true
[queue]
TYPE = level
[repository]
ROOT = /data/gitea/app_data/repositories
DISABLE_FORK_TIME_CHECK = true
MAX_CREATION_LIMIT = 0
[picture]
AVATAR_UPLOAD_PATH = /data/gitea/app_data/repositories/avatars
REPOSITORY_AVATAR_UPLOAD_PATH = /data/gitea/app_data/repositories/repo-avatars
[attachment]
STORAGE_TYPE = local
PATH = /data/gitea/app_data/repositories/attachments
[lfs]
STORAGE_TYPE = local
PATH = /data/gitea/app_data/repositories/lfs
[repo-archive]
STORAGE_TYPE = local
PATH = /data/gitea/app_data/repositories/repo-archive
EOF
# Ensure the config file is fully readable and writeable by the git user
chown git:git "$CONF_PATH"
# 5. Drop Root Privileges and boot the Gitea Web server pointing to our manual config
echo "[Gitea] Dropping privileges to 'git' user and booting web service core..."
exec su git -c "/app/gitea/gitea web --config $CONF_PATH --port 3000"
+6
View File
@@ -0,0 +1,6 @@
dbs:
- path: /data/gitea/gitea.db
replicas:
- type: gcs
bucket: "${GCS_BUCKET_NAME}"
path: "database"