feat: update Forgejo deployment
add DNS update step and complete forgejo deployment after build
This commit is contained in:
parent
8faa97a8bb
commit
8f19558826
7 changed files with 139 additions and 1 deletions
|
|
@ -26,7 +26,7 @@ spec:
|
||||||
- name: FORGEJO__repository__ENABLE_PUSH_CREATE_USER
|
- name: FORGEJO__repository__ENABLE_PUSH_CREATE_USER
|
||||||
value: "true"
|
value: "true"
|
||||||
- name: FORGEJO__server__ROOT_URL
|
- name: FORGEJO__server__ROOT_URL
|
||||||
value: "https://frg.headshed.dev/"
|
value: "https://frgdr.headshed.dev/"
|
||||||
- name: FORGEJO__repository__DEFAULT_BRANCH
|
- name: FORGEJO__repository__DEFAULT_BRANCH
|
||||||
value: "main"
|
value: "main"
|
||||||
- name: FORGEJO__server__LFS_START_SERVER
|
- name: FORGEJO__server__LFS_START_SERVER
|
||||||
|
|
|
||||||
56
gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json
Normal file
56
gcloud/tf/scripts/build-gcloud-k3s-pipeline-wait-dns.json
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "run pre-flight checks",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./gcloud/tf/scripts/pre-flight-checks.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "list gcloud infrastructure",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./gcloud/tf/scripts/list_gloud_infra.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "create tfvars",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./gcloud/tf/scripts/create_tfvars.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "run tofu",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./gcloud/tf/scripts/run_tofu.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "wait for user input to continue",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"./gcloud/tf/scripts/wait_for_user_input_dns.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "copy .env to k3s-vm-1",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"gcloud/tf/scripts/copy_env_to_first_node.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -34,5 +34,14 @@
|
||||||
],
|
],
|
||||||
"retryCount": 0,
|
"retryCount": 0,
|
||||||
"shouldAbort": true
|
"shouldAbort": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "copy .env to k3s-vm-1",
|
||||||
|
"function": "RunCommand",
|
||||||
|
"params": [
|
||||||
|
"gcloud/tf/scripts/copy_env_to_first_node.sh"
|
||||||
|
],
|
||||||
|
"retryCount": 0,
|
||||||
|
"shouldAbort": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
31
gcloud/tf/scripts/copy_env_to_first_node.sh
Executable file
31
gcloud/tf/scripts/copy_env_to_first_node.sh
Executable file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
source .env
|
||||||
|
|
||||||
|
for i in {1..10}; do
|
||||||
|
# Check if the instance is running
|
||||||
|
INSTANCE_STATUS=$(gcloud compute instances describe k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --format='get(status)')
|
||||||
|
if [[ "$INSTANCE_STATUS" != "RUNNING" ]]; then
|
||||||
|
echo "Instance k3s-vm-1 is not running. Attempt $i/10. Waiting 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if the directory exists on the remote host
|
||||||
|
if gcloud compute ssh k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --command="test -d /opt/src/infctl-cli/"; then
|
||||||
|
echo "/opt/src/infctl-cli/ exists on k3s-vm-1."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "/opt/src/infctl-cli/ does not exist yet. Attempt $i/10. Waiting 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Final check after loop
|
||||||
|
if ! gcloud compute ssh k3s-vm-1 --zone=us-central1-a --project="$PROJECT_NAME" --command="test -d /opt/src/infctl-cli/"; then
|
||||||
|
echo "ERROR: /opt/src/infctl-cli/ does not exist on k3s-vm-1 after 10 attempts. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
gcloud compute scp .env k3s-vm-1:/opt/src/infctl-cli/.env --zone=us-central1-a --project=$PROJECT_NAME
|
||||||
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Redirect all output to a log file for reliability
|
||||||
|
exec > /tmp/startup.log 2>&1
|
||||||
|
|
||||||
INFCTL_GIT_REPO="https://codeberg.org/headshed/infctl-cli.git"
|
INFCTL_GIT_REPO="https://codeberg.org/headshed/infctl-cli.git"
|
||||||
INFCTL_GIT_REPO_BRANCH="main"
|
INFCTL_GIT_REPO_BRANCH="main"
|
||||||
INFCTL_INSTALL_DIR="/opt/src"
|
INFCTL_INSTALL_DIR="/opt/src"
|
||||||
|
|
@ -100,3 +103,31 @@ if [[ ! -d "$INFCTL_INSTALL_DIR" ]]; then
|
||||||
chown -R user:user "$INFCTL_INSTALL_DIR"
|
chown -R user:user "$INFCTL_INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
for i in {1..100}; do
|
||||||
|
if [[ -f /opt/src/infctl-cli/.env ]]; then
|
||||||
|
echo ".env file found."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo ".env file not found. Attempt $i/100. Waiting 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Final check after loop
|
||||||
|
if [[ ! -f /opt/src/infctl-cli/.env ]]; then
|
||||||
|
echo "ERROR: .env file not found after 10 attempts. Exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# load .env file
|
||||||
|
source /opt/src/infctl-cli/.env
|
||||||
|
|
||||||
|
# check to see if INSTALL_FORGEJO is set to "true"
|
||||||
|
if [[ "$INSTALL_FORGEJO" == "true" ]]; then
|
||||||
|
# install forgejo using infctl
|
||||||
|
# ....
|
||||||
|
export KUBECONFIG=/etc/rancher/k3s/k3s.yaml
|
||||||
|
LOG_FORMAT=none infctl -f "${INFCTL_INSTALL_DIR}/infctl-cli/gcloud/tf/scripts/install-forgejo-pipeline.json"
|
||||||
|
touch /etc/forgejo_was_installed
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
|
||||||
11
gcloud/tf/scripts/wait_for_user_input_dns.sh
Executable file
11
gcloud/tf/scripts/wait_for_user_input_dns.sh
Executable file
|
|
@ -0,0 +1,11 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
echo "Please configure DNS using the IP address from the previous stage."
|
||||||
|
echo "you have 120 seconds."
|
||||||
|
for i in {120..1}; do
|
||||||
|
echo -ne "Time remaining: $i seconds\r"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
exit 0
|
||||||
Loading…
Add table
Add a link
Reference in a new issue