refactor: Migrate Gitea to Podman
- Migrate Gitea installation to use Podman containers. - This simplifies the installation process and improves - portability. Removes reliance on direct binary - downloads and manual installation steps. The - Gitea instance is now managed as a container. - Updates configuration to reflect container-based - deployment. Updates version to 'latest' to - leverage Podman's image management capabilities. Co-authored-by: mariobassem12 <mariobassem12@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -no-retry-compilation -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import freeflowuniverse.herolib.installers.gitea
|
||||
import freeflowuniverse.herolib.installers.infra.gitea
|
||||
|
||||
mut g := gitea.new(
|
||||
passwd: '123'
|
||||
|
||||
@@ -2,35 +2,27 @@ module gitea
|
||||
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.core
|
||||
// import freeflowuniverse.herolib.core.base
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
// import freeflowuniverse.herolib.osal.systemd
|
||||
import freeflowuniverse.herolib.installers.base
|
||||
import freeflowuniverse.herolib.installers.ulist
|
||||
import freeflowuniverse.herolib.installers.lang.golang
|
||||
import freeflowuniverse.herolib.installers.lang.rust
|
||||
import freeflowuniverse.herolib.installers.lang.python
|
||||
import freeflowuniverse.herolib.installers.db.postgresql as postgresinstaller
|
||||
import freeflowuniverse.herolib.installers.virt.podman as podman_installer
|
||||
import freeflowuniverse.herolib.osal.zinit
|
||||
import os
|
||||
|
||||
// checks if a certain version or above is installed
|
||||
fn installed() !bool {
|
||||
// THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED
|
||||
cfg := get()!
|
||||
res := os.execute('/bin/bash -c "gitea --version"')
|
||||
if res.exit_code != 0 {
|
||||
mut cfg := get()!
|
||||
mut podman := podman_installer.get()!
|
||||
podman.install()!
|
||||
|
||||
cmd := 'podman healthcheck run ${cfg.container_name}'
|
||||
result := os.execute(cmd)
|
||||
|
||||
if result.exit_code != 0 {
|
||||
return false
|
||||
}
|
||||
r := res.output.split(' ')
|
||||
if r.len < 3 {
|
||||
return error("couldn't parse gitea version.\n${res.output}")
|
||||
}
|
||||
if texttools.version(cfg.version) > texttools.version(r[2]) {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
fn install() ! {
|
||||
@@ -47,27 +39,15 @@ fn install() ! {
|
||||
|
||||
// make sure we install base on the node
|
||||
base.install()!
|
||||
postgresinstaller.install()!
|
||||
|
||||
mut postgres := postgresinstaller.get()!
|
||||
postgres.install()!
|
||||
|
||||
cfg := get()!
|
||||
version := cfg.version
|
||||
url := 'https://github.com/go-gitea/gitea/releases/download/v${version}/gitea-${version}-linux-amd64.xz'
|
||||
console.print_debug(' download ${url}')
|
||||
mut dest := osal.download(
|
||||
url: url
|
||||
minsize_kb: 40000
|
||||
reset: true
|
||||
expand_file: '/tmp/download/gitea'
|
||||
)!
|
||||
|
||||
binpath := pathlib.get_file(path: dest.path, create: false)!
|
||||
osal.cmd_add(
|
||||
cmdname: 'gitea'
|
||||
source: binpath.path
|
||||
)!
|
||||
|
||||
osal.done_set('gitea_install', 'OK')!
|
||||
mut podman := podman_installer.get()!
|
||||
podman.install()!
|
||||
|
||||
osal.execute_silent('podman pull docker.io/gitea/gitea:${cfg.version}')!
|
||||
console.print_header('gitea installed properly.')
|
||||
}
|
||||
|
||||
@@ -88,7 +68,7 @@ fn stop_post() ! {
|
||||
}
|
||||
|
||||
fn destroy() ! {
|
||||
server := get()!
|
||||
mut server := get()!
|
||||
server.stop()!
|
||||
|
||||
osal.process_kill_recursive(name: 'gitea')!
|
||||
|
||||
@@ -37,7 +37,8 @@ pub mut:
|
||||
name string = 'default'
|
||||
|
||||
// reset bool
|
||||
version string = '1.22.4'
|
||||
container_name string = 'herocontainer_gitea'
|
||||
version string = 'latest'
|
||||
path string = '/data/gitea'
|
||||
passwd string
|
||||
postgresql_name string = 'default'
|
||||
@@ -66,7 +67,7 @@ fn cfg_play(p paramsparser.Params) !GiteaServer {
|
||||
mail_from: p.get_default('mail_from', 'git@meet.tf')!
|
||||
smtp_addr: p.get_default('smtp_addr', 'smtp-relay.brevo.com')!
|
||||
smtp_login: p.get('smtp_login')!
|
||||
smpt_port: p.get_int_default('smpt_port', 587)!
|
||||
smtp_port: p.get_int_default('smtp_port', 587)!
|
||||
smtp_passwd: p.get('smtp_passwd')!
|
||||
domain: p.get('domain')!
|
||||
jwt_secret: p.get('jwt_secret')!
|
||||
|
||||
Reference in New Issue
Block a user