114 lines
3.3 KiB
Markdown
114 lines
3.3 KiB
Markdown
# Estructura inicial del proyecto
|
|
|
|
```bash
|
|
gitea-rc4 $ tree -a
|
|
.
|
|
├── docker-compose.override.yml
|
|
├── docker-compose.yml
|
|
└── .env
|
|
```
|
|
|
|
_Nota autor:_ algunos datos en este documento pueden estar ofuscados.
|
|
|
|
## Configuración y ejecución de los contenedores Docker
|
|
|
|
### Configuración autenticación ssh - Docker Shell (with authorized_keys)
|
|
|
|
_Referencia principal:_ [Installation with Docker](https://docs.gitea.com/installation/install-with-docker#docker-shell-with-authorized_keys) - Docker Shell (with authorized_keys).
|
|
|
|
### Configuración de la aplicación y usario de Gitea
|
|
|
|
En el host motor de Docker se realizan las siguientes tareas de configuración. Estas son:
|
|
|
|
```
|
|
source .env
|
|
export CONTAINER_NAME GITEA_ACCOUNT GITEA_UID GITEA_GID
|
|
sudo groupadd -g ${GITEA_UID} ${GITEA_ACCOUNT}
|
|
sudo useradd -u ${GITEA_UID} -g ${GITEA_GID} -G docker -d /home/${GITEA_ACCOUNT} ${GITEA_ACCOUNT}
|
|
#sudo usermod -G docker -a ${GITEA_ACCOUNT}
|
|
sudo -u ${GITEA_ACCOUNT} ssh-keygen -t rsa -b 4096 -C "Gitea Host Key"
|
|
|
|
sudo -u ${GITEA_ACCOUNT} cat /home/${GITEA_ACCOUNT}/.ssh/id_rsa.pub | sudo -u ${GITEA_ACCOUNT} tee -a /home/${GITEA_ACCOUNT}/.ssh/authorized_keys
|
|
sudo -u ${GITEA_ACCOUNT} chmod 600 /home/${GITEA_ACCOUNT}/.ssh/authorized_keys
|
|
|
|
cat <<EOF | sudo tee /home/${GITEA_ACCOUNT}/docker-shell
|
|
#!/bin/sh
|
|
/usr/bin/docker exec -i -u ${GITEA_ACCOUNT} --env SSH_ORIGINAL_COMMAND="\$SSH_ORIGINAL_COMMAND" ${CONTAINER_NAME} sh "\$@"
|
|
EOF
|
|
sudo chmod +x /home/${GITEA_ACCOUNT}/docker-shell
|
|
sudo usermod -s /home/${GITEA_ACCOUNT}/docker-shell ${GITEA_ACCOUNT}
|
|
|
|
# id ${GITEA_ACCOUNT} # <-- el usuario git sobre el host anfitrion debe poder ejecutar docker para esta configuración funcione (es el usuario que redirecciona la conexión ssh al propio contenedor de Gitea).
|
|
##$ id ${GITEA_ACCOUNT}
|
|
## uid=...(git) gid=...(git) groups=...(git),...(docker)
|
|
```
|
|
|
|
## Revisar/ajustar estructura
|
|
|
|
```bash
|
|
mkdir -pv data/{gitea,postgres}
|
|
```
|
|
|
|
### Estructura (sugerida) antes de ejcutar los contenedores
|
|
|
|
```bash
|
|
gitea-rc4]$ tree -a
|
|
.
|
|
├── data # Carpeta para los volúmenes persistentes
|
|
│ ├── gitea
|
|
│ └── postgres
|
|
├── docker-compose.override.yml
|
|
├── docker-compose.yml
|
|
├── .env
|
|
└── gitea-rc4.md
|
|
```
|
|
|
|
## Iniciar los contenedores
|
|
|
|
```
|
|
docker compose up -d
|
|
```
|
|
|
|
## Instalar Gitea
|
|
|
|
Acceder a: `http://localhost:<$GITEA_HTTP_PORT_EXTERNAL>` e instalar Gitea
|
|
|
|

|
|
|
|
## Registrar usuario y copiar credenciales
|
|
|
|
En esta sección se registra un usuario y se copia su clave pública.
|
|
|
|
### Registrar usuario
|
|
|
|

|
|
|
|
### Usuario logado - setting
|
|
|
|

|
|
|
|
#### Setting - copiar clave pública
|
|
|
|

|
|
|
|
### Utilización de Gitea
|
|
|
|
En las siguientes capturas se muestran ejemplo como copiar/clonar dos repositorios que el usuario `userdevel1`. Uno mediante el URL sobre `http` y el otro mediante `ssh`.
|
|
|
|
- `git clone http://almalinux9-docker:3000/usrdevel1/repositorio1.git`
|
|
|
|

|
|
|
|
- `git clone git@almalinux9-docker:usrdevel1/repo-2.git`
|
|
|
|

|
|
|
|
## Otros comandos
|
|
|
|
- Ver los logs
|
|
|
|
```bash
|
|
docker-compose logs -f
|
|
```
|
|
|