Add 15 and update 3 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 47s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 47s
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# See https://caddyserver.com/docs/caddyfile
|
||||
|
||||
localhost {
|
||||
root * /srv
|
||||
root * /static
|
||||
file_server
|
||||
}
|
||||
|
||||
@@ -5,3 +5,8 @@ IMAGE_TAG="latest"
|
||||
|
||||
# Server Settings
|
||||
SSH_USER="root"
|
||||
|
||||
# Static files directory (optional)
|
||||
# If set, maps this host directory to /static in the container
|
||||
# If empty, uses the default config/static directory
|
||||
HOST_STATIC_DIR=""
|
||||
|
||||
@@ -10,6 +10,13 @@ if [ ! -f "${CONFIG_PATH}/caddyfile/Caddyfile" ]; then
|
||||
_die "Caddyfile not found in ${CONFIG_PATH}/caddyfile/Caddyfile"
|
||||
fi
|
||||
|
||||
# Determine static files directory
|
||||
# Use HOST_STATIC_DIR if set, otherwise use config/static
|
||||
if [ -n "${HOST_STATIC_DIR}" ]; then
|
||||
STATIC_DIR="${HOST_STATIC_DIR}"
|
||||
else
|
||||
STATIC_DIR="${CONFIG_PATH}/static"
|
||||
fi
|
||||
|
||||
DOCKER_RUN_CMD="docker run -d \
|
||||
--restart unless-stopped \
|
||||
@@ -21,7 +28,7 @@ DOCKER_RUN_CMD="docker run -d \
|
||||
-v ${CONFIG_PATH}/caddyfile:/etc/caddy \
|
||||
-v ${DATA_VOLUME}:/data \
|
||||
-v ${CONFIG_VOLUME}:/config \
|
||||
-v ${CONFIG_PATH}/static:/srv \
|
||||
-v ${STATIC_DIR}:/static \
|
||||
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
||||
|
||||
|
||||
|
||||
70
gitea-server/README.txt
Normal file
70
gitea-server/README.txt
Normal file
@@ -0,0 +1,70 @@
|
||||
Gitea Server Template
|
||||
=====================
|
||||
|
||||
A lightweight, self-hosted Git service. Gitea is a painless self-hosted Git
|
||||
service similar to GitHub, GitLab, and Bitbucket.
|
||||
|
||||
Features:
|
||||
- Git repository hosting
|
||||
- Issue tracking
|
||||
- Pull requests / code review
|
||||
- Wiki
|
||||
- CI/CD integration (with Gitea Actions or external runners)
|
||||
- User and organization management
|
||||
- Web-based interface
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Edit config/service.env to customize:
|
||||
|
||||
CONTAINER_NAME - Name of the Docker container (default: gitea)
|
||||
IMAGE_TAG - Docker image tag (default: latest)
|
||||
HTTP_PORT - Web interface port (default: 3000)
|
||||
SSH_PORT - Git SSH port (default: 2222)
|
||||
|
||||
Ports
|
||||
-----
|
||||
|
||||
HTTP_PORT (default 3000) - Web interface and HTTP Git operations
|
||||
SSH_PORT (default 2222) - SSH Git operations
|
||||
|
||||
First-Time Setup
|
||||
----------------
|
||||
|
||||
After installation, access Gitea at http://your-server:HTTP_PORT to complete
|
||||
the initial configuration wizard. You'll need to set:
|
||||
|
||||
- Database type (SQLite3 is recommended for small installations)
|
||||
- Site title and base URL
|
||||
- Administrator account
|
||||
|
||||
Data Storage
|
||||
------------
|
||||
|
||||
All data is stored in a Docker volume named ${CONTAINER_NAME}_data which
|
||||
includes:
|
||||
- Git repositories
|
||||
- Database (if using SQLite)
|
||||
- User uploads and attachments
|
||||
- Configuration files
|
||||
|
||||
Backup
|
||||
------
|
||||
|
||||
Use the backup.sh script to create backups of all Gitea data. The backup
|
||||
includes repositories, database, and configuration.
|
||||
|
||||
SSH Clone URLs
|
||||
--------------
|
||||
|
||||
To clone via SSH, users should use:
|
||||
git clone ssh://git@your-server:SSH_PORT/username/repo.git
|
||||
|
||||
Or configure SSH config for easier access.
|
||||
|
||||
More Information
|
||||
----------------
|
||||
|
||||
Gitea documentation: https://docs.gitea.io/
|
||||
Docker image: https://hub.docker.com/r/gitea/gitea
|
||||
7
gitea-server/_volumes.sh
Executable file
7
gitea-server/_volumes.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Define volume items for gitea container
|
||||
# These are used across backup, restore, create, and destroy operations
|
||||
|
||||
get_gitea_volumes() {
|
||||
echo "volume:datavolume:${DATA_VOLUME}"
|
||||
}
|
||||
18
gitea-server/backup.sh
Executable file
18
gitea-server/backup.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/_volumes.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME"
|
||||
|
||||
# BACKUP SCRIPT
|
||||
# Creates a backup of the Gitea data volume
|
||||
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
|
||||
# shellcheck disable=SC2046
|
||||
backup_items $(get_gitea_volumes) || _die "Failed to create backup"
|
||||
|
||||
_start_container "$CONTAINER_NAME"
|
||||
|
||||
echo "Backup created successfully"
|
||||
16
gitea-server/config/.template_info.env
Normal file
16
gitea-server/config/.template_info.env
Normal file
@@ -0,0 +1,16 @@
|
||||
# DO NOT EDIT THIS FILE FOR YOUR SERVICE!
|
||||
# This file is replaced from the template whenever there is an update.
|
||||
# Edit the service.env file to make changes.
|
||||
|
||||
# Template to use - always required!
|
||||
TEMPLATE=gitea-server
|
||||
REQUIRES_HOST_ROOT=false
|
||||
REQUIRES_DOCKER=true
|
||||
REQUIRES_DOCKER_ROOT=false
|
||||
|
||||
# Image settings
|
||||
IMAGE_REGISTRY="docker.io"
|
||||
IMAGE_REPO="gitea/gitea"
|
||||
|
||||
# Volume settings
|
||||
DATA_VOLUME="${CONTAINER_NAME}_data"
|
||||
11
gitea-server/config/service.env
Normal file
11
gitea-server/config/service.env
Normal file
@@ -0,0 +1,11 @@
|
||||
# Service settings specific to this server
|
||||
# (can also override anything in the .template_info.env file in the template to make it specific to this server)
|
||||
CONTAINER_NAME=gitea
|
||||
IMAGE_TAG="latest"
|
||||
|
||||
# Server Settings
|
||||
SSH_USER="root"
|
||||
|
||||
# Gitea ports
|
||||
HTTP_PORT=3000
|
||||
SSH_PORT=2222
|
||||
20
gitea-server/destroy.sh
Executable file
20
gitea-server/destroy.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/_volumes.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME"
|
||||
|
||||
# DESTROY SCRIPT
|
||||
# Completely removes the service AND all data
|
||||
# WARNING: This is irreversible!
|
||||
|
||||
echo "WARNING: This will PERMANENTLY DELETE all data for ${CONTAINER_NAME}"
|
||||
echo "This includes all repositories, users, and configuration!"
|
||||
|
||||
./uninstall.sh
|
||||
|
||||
# shellcheck disable=SC2046
|
||||
destroy_items $(get_gitea_volumes) || _die "Failed to destroy docker volumes"
|
||||
|
||||
echo "Destroyed ${CONTAINER_NAME} and all data."
|
||||
19
gitea-server/install.sh
Executable file
19
gitea-server/install.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/_volumes.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME"
|
||||
|
||||
# shellcheck disable=SC2046
|
||||
create_items $(get_gitea_volumes) || _die "Failed to create volume $DATA_VOLUME"
|
||||
|
||||
_check_docker_installed || _die "Docker test failed, aborting installation..."
|
||||
|
||||
docker pull "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || _die "Failed to pull image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
|
||||
|
||||
bash ./stop.sh || _die "Failed to stop container ${CONTAINER_NAME}"
|
||||
_remove_container "$CONTAINER_NAME" || _die "Failed to remove container ${CONTAINER_NAME}"
|
||||
bash ./start.sh || _die "Failed to start container ${CONTAINER_NAME}"
|
||||
|
||||
echo "Installation of ${CONTAINER_NAME} complete"
|
||||
11
gitea-server/logs.sh
Executable file
11
gitea-server/logs.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# LOGS SCRIPT
|
||||
# Shows the container logs
|
||||
|
||||
echo "Container ${CONTAINER_NAME} logs:"
|
||||
_grey_start
|
||||
docker logs "${CONTAINER_NAME}" "$@"
|
||||
_grey_end
|
||||
9
gitea-server/ports.sh
Executable file
9
gitea-server/ports.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "HTTP_PORT" "SSH_PORT"
|
||||
|
||||
# PORTS SCRIPT
|
||||
# Lists the exposed ports
|
||||
|
||||
echo "$HTTP_PORT"
|
||||
echo "$SSH_PORT"
|
||||
21
gitea-server/restore.sh
Executable file
21
gitea-server/restore.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/_volumes.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "DATA_VOLUME"
|
||||
|
||||
# RESTORE SCRIPT
|
||||
# Restores Gitea data from a backup
|
||||
|
||||
# Uninstall container before restore
|
||||
./uninstall.sh || _die "Failed to uninstall service before restore"
|
||||
|
||||
# Restore data from backup file
|
||||
# shellcheck disable=SC2046
|
||||
restore_items $(get_gitea_volumes) || _die "Failed to restore data from backup file"
|
||||
|
||||
# Reinstall service
|
||||
./install.sh || _die "Failed to reinstall service after restore"
|
||||
|
||||
echo "Restore complete! Service is running again."
|
||||
8
gitea-server/ssh.sh
Executable file
8
gitea-server/ssh.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# SSH SCRIPT
|
||||
# Opens a shell inside the container
|
||||
|
||||
docker exec -it "${CONTAINER_NAME}" /bin/bash
|
||||
30
gitea-server/start.sh
Executable file
30
gitea-server/start.sh
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" "DATA_VOLUME" "HTTP_PORT" "SSH_PORT"
|
||||
|
||||
# START SCRIPT
|
||||
# The start script is required for all templates.
|
||||
# It is used to start the service on the server.
|
||||
|
||||
DOCKER_RUN_CMD="docker run -d \
|
||||
--restart unless-stopped \
|
||||
--name ${CONTAINER_NAME} \
|
||||
-p ${HTTP_PORT}:3000 \
|
||||
-p ${SSH_PORT}:22 \
|
||||
-v ${DATA_VOLUME}:/data \
|
||||
-e USER_UID=1000 \
|
||||
-e USER_GID=1000 \
|
||||
${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}"
|
||||
|
||||
if ! _create_and_start_container "$DOCKER_RUN_CMD" "$CONTAINER_NAME"; then
|
||||
_die "Failed to start container ${CONTAINER_NAME}"
|
||||
fi
|
||||
|
||||
# Check if the container is running
|
||||
if ! _is_container_running "$CONTAINER_NAME"; then
|
||||
_die "Container ${CONTAINER_NAME} is not running"
|
||||
fi
|
||||
|
||||
echo "Container ${CONTAINER_NAME} started"
|
||||
echo "Access Gitea at http://localhost:${HTTP_PORT}"
|
||||
echo "SSH clone available on port ${SSH_PORT}"
|
||||
31
gitea-server/status.sh
Executable file
31
gitea-server/status.sh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# STATUS SCRIPT
|
||||
# The status script is REQUIRED.
|
||||
# It is used to return the status of the service.
|
||||
# Must output exactly one of: Running, Stopped, Error, Unknown
|
||||
|
||||
# Check if container exists
|
||||
if ! docker ps -a --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
|
||||
echo "Unknown"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Check container state
|
||||
STATE=$(docker inspect -f '{{.State.Status}}' "$CONTAINER_NAME" 2>/dev/null)
|
||||
case "$STATE" in
|
||||
running)
|
||||
echo "Running"
|
||||
;;
|
||||
exited|stopped)
|
||||
echo "Stopped"
|
||||
;;
|
||||
restarting|paused)
|
||||
echo "Error"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown"
|
||||
;;
|
||||
esac
|
||||
11
gitea-server/stop.sh
Executable file
11
gitea-server/stop.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME"
|
||||
|
||||
# STOP SCRIPT
|
||||
# The stop script is required for all templates.
|
||||
# It is used to stop the service on the server.
|
||||
|
||||
_stop_container $CONTAINER_NAME || _die "Failed to stop container ${CONTAINER_NAME}"
|
||||
|
||||
echo "Container ${CONTAINER_NAME} stopped"
|
||||
18
gitea-server/uninstall.sh
Executable file
18
gitea-server/uninstall.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG"
|
||||
|
||||
# UNINSTALL SCRIPT
|
||||
# The uninstall script is required for all templates.
|
||||
# It is used to uninstall the service from the server.
|
||||
# IMPORTANT: This script MUST preserve data volumes!
|
||||
|
||||
_remove_container "$CONTAINER_NAME" || _die "Failed to remove container ${CONTAINER_NAME}"
|
||||
_is_container_running "$CONTAINER_NAME" && _die "Couldn't stop existing container"
|
||||
_is_container_exists "$CONTAINER_NAME" && _die "Couldn't remove existing container"
|
||||
|
||||
# Remove the image
|
||||
docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"
|
||||
|
||||
echo "Uninstallation of ${CONTAINER_NAME} complete."
|
||||
echo "Data volume preserved. To remove all data, use destroy.sh"
|
||||
Reference in New Issue
Block a user