aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.env3
-rw-r--r--README.md31
-rw-r--r--docker-compose.yml80
-rw-r--r--etc/Caddyfile7
4 files changed, 121 insertions, 0 deletions
diff --git a/.env b/.env
new file mode 100644
index 0000000..2ae4c8e
--- /dev/null
+++ b/.env
@@ -0,0 +1,3 @@
+FORGEJO_DATABASE=forgejo
+FORGEJO_USERNAME=forgejo
+FORGEJO_PASSWORD=p@sswOrd \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..5c0872d
--- /dev/null
+++ b/README.md
@@ -0,0 +1,31 @@
+Порезанная версия сервиса gitrepo
+
+## Установка
+
+1. Ставим на серваке Docker (https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository)
+2. Копируем все файлы на сервер
+3. Редактируем файл .env под себя и указываем правильный домен в файле etc/Caddyfile
+3. Выполняем в директории с файлами команду
+ ```
+ docker compose up -d
+ ```
+4. Настраиваем SSH:
+ ```
+ adduser \
+ --system \
+ --shell /bin/bash \
+ --gecos 'Git Version Control' \
+ --group \
+ --disabled-password \
+ --home /home/git \
+ git
+ ```
+5. Добавляем в /etc/ssh/sshd_config
+ ```
+ Match User git
+ AuthorizedKeysCommandUser git
+ AuthorizedKeysCommand /usr/bin/docker exec -i git /usr/local/bin/forgejo keys -e git -u %u -t %t -k %k
+ PasswordAuthentication no
+ ```
+## Если не завелось
+1. Смотрим статус сервисов - \ No newline at end of file
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..9e72601
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,80 @@
+version: "3"
+
+services:
+ caddy:
+ image: caddy:2.6.2-alpine
+ container_name: gateway
+ restart: always
+ ports:
+ - "80:80"
+ - "443:443"
+ - "443:443/udp"
+ volumes:
+ - ./etc/Caddyfile:/etc/caddy/Caddyfile
+ - caddy_data:/data
+ networks:
+ - gateway
+
+ forgejo_server:
+ image: codeberg.org/forgejo/forgejo:1.20.5-0
+ container_name: git
+ env_file:
+ - .env
+ environment:
+ - USER_UID=1001
+ - USER_GID=1001
+ - TZ=Europe/Moscow
+ - USER=git
+ - FORGEJO__database__DB_TYPE=postgres
+ - FORGEJO__database__HOST=forgejo_db:5432
+ - FORGEJO__database__NAME=${FORGEJO_DATABASE}
+ - FORGEJO__database__USER=${FORGEJO_USERNAME}
+ - FORGEJO__database__PASSWD=${FORGEJO_PASSWORD}
+ - FORGEJO__server__DISABLE_SSH = false
+ - FORGEJO__server__SSH_PORT = 22
+ - FORGEJO__server__SSH_LISTEN_PORT = 22
+ restart: always
+ networks:
+ - forgejo
+ - gateway
+ volumes:
+ - /home/git/.ssh/:/data/git/.ssh
+ - ./data:/data
+ - /etc/timezone:/etc/timezone:ro
+ - /etc/localtime:/etc/localtime:ro
+ ports:
+ - "127.0.0.1:2222:22"
+ depends_on:
+ - forgejo_db
+
+ forgejo_db:
+ image: postgres:13-alpine
+ container_name: forgejo_db
+ restart: always
+ env_file:
+ - .env
+ environment:
+ - USER_UID=1001
+ - USER_GID=1001
+ - TZ=Europe/Moscow
+ - POSTGRES_DATABASE=${FORGEJO_DATABASE}
+ - POSTGRES_USER=${FORGEJO_USERNAME}
+ - POSTGRES_PASSWORD=${FORGEJO_PASSWORD}
+ healthcheck:
+ test: /usr/bin/pg_isready -U ${FORGEJO_USERNAME} -d ${FORGEJO_DATABASE}
+ interval: 5s
+ timeout: 10s
+ retries: 120
+ networks:
+ - forgejo
+ volumes:
+ - forgejo_db_data:/var/lib/postgresql/data
+
+volumes:
+ caddy_data:
+ forgejo_db_data:
+
+networks:
+ gateway:
+ forgejo:
+ external: false
diff --git a/etc/Caddyfile b/etc/Caddyfile
new file mode 100644
index 0000000..641a772
--- /dev/null
+++ b/etc/Caddyfile
@@ -0,0 +1,7 @@
+:80 {
+ root * /usr/share/caddy
+ file_server
+}
+gitrepo.ru {
+ reverse_proxy forgejo_server:3000
+}