adding the config files for deploying this remote
This commit is contained in:
commit
35a1af7852
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
.env
|
||||
18
Dockerfile
Normal file
18
Dockerfile
Normal 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"]
|
||||
20
README.md
Normal file
20
README.md
Normal file
@ -0,0 +1,20 @@
|
||||
## 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`
|
||||
|
||||
```
|
||||
gcloud run deploy gitea-serverless \
|
||||
--source . \
|
||||
--region europe-west1 \
|
||||
--allow-unauthenticated \
|
||||
--max-instances 1 \
|
||||
--memory 512Mi \
|
||||
--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"
|
||||
```
|
||||
56
entrypoint.sh
Normal file
56
entrypoint.sh
Normal file
@ -0,0 +1,56 @@
|
||||
#!/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 and hand ownership to the 'git' user
|
||||
mkdir -p "$CONF_DIR"
|
||||
mkdir -p /data/gitea/app_data
|
||||
chown -R git:git /data
|
||||
|
||||
# 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 (Bypasses all Gitea wizards)
|
||||
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
|
||||
|
||||
[repository]
|
||||
ROOT = /data/gitea/app_data/repositories
|
||||
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
litestream.yml
Normal file
6
litestream.yml
Normal file
@ -0,0 +1,6 @@
|
||||
dbs:
|
||||
- path: /data/gitea/gitea.db
|
||||
replicas:
|
||||
- type: gcs
|
||||
bucket: "${GCS_BUCKET_NAME}"
|
||||
path: "database"
|
||||
Loading…
Reference in New Issue
Block a user