Skip to content

Commit

Permalink
feat(service): add gitea and zot
Browse files Browse the repository at this point in the history
  • Loading branch information
borjapazr committed Aug 22, 2023
1 parent 3704224 commit 26dcbfb
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
**/netdata/config/health_alarm_notify.conf
**/netdata/config/.container-hostname
**/traefik/credentials
**/zot/credentials
**/*.private
**/_*/
**/_*
Expand Down
19 changes: 19 additions & 0 deletions services/gitea/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Volume settings ##
VOLUME_DIR=

## Domain settings ##
DOMAIN=

# Database configuration #
DB_USER=
DB_PASSWORD=
DB_NAME=

## Email settings ##
SMTP_HOST=
SMTP_PORT=
SMTP_USER=
SMTP_PASSWORD=

## Timezone configuration ##
TZ=
15 changes: 15 additions & 0 deletions services/gitea/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SERVICE := gitea
include $(ROOT_DIR)/../../core/common.mk
include .env

.ONESHELL:

.PHONY: install
install: ## Start all containers in background
@$(DOCKER_COMPOSE) up -d

.PHONY: uninstall
uninstall: ## Stop all containers and remove all data
@$(DOCKER_COMPOSE) down -v
@sudo rm -rf $(VOLUME_DIR)
80 changes: 80 additions & 0 deletions services/gitea/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
version: "3.7"

services:
### Gitea: A lightweight DevOps platform. ###
gitea:
image: gitea/gitea:1.20.2
container_name: gitea
restart: always
depends_on:
- gitea-postgresql
environment:
- USER=git
- USER_UID=1000
- USER_GID=1000
- GITEA__database__DB_TYPE=postgres
- GITEA__database__HOST=gitea-postgresql:5432
- GITEA__database__USER=${DB_USER}
- GITEA__database__PASSWD=${DB_PASSWORD}
- GITEA__database__NAME=${DB_NAME}
- GITEA__mailer__ENABLED=true
- GITEA__mailer__PROTOCOL=smtps
- GITEA__mailer__FROM=${MAIL}
- GITEA__mailer__SMTP_ADDR=${SMTP_HOST}
- GITEA__mailer__SMTP_PORT=${SMTP_PORT}
- GITEA__mailer__USER=${SMTP_USER}
- GITEA__mailer__PASSWD=${SMTP_PASSWORD}
- GITEA__service__DISABLE_REGISTRATION=true
- TZ=${TZ}
volumes:
- ${VOLUME_DIR}/data:/var/lib/gitea
- ${VOLUME_DIR}/config:/etc/gitea
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
networks:
- default
- traefik-network
labels:
## Watchtower configuration ##
- com.centurylinklabs.watchtower.enable=true
- com.centurylinklabs.watchtower.monitor-only=true

## Diun configuration ##
- diun.enable=true

## Traefik configuration ##
# Enable Traefik #
- traefik.enable=true
- traefik.docker.network=traefik-network

# Set entrypoint port #
- traefik.http.services.gitea.loadbalancer.server.port=3000

# Set HTTP domain and HTTP -> HTTPS redirection #
- traefik.http.routers.gitea.rule=Host(`${DOMAIN}`)
- traefik.http.routers.gitea.entrypoints=web
- traefik.http.routers.gitea.middlewares=https-redirect@file

# Set HTTPS domain #
- traefik.http.routers.gitea-secure.rule=Host(`${DOMAIN}`)
- traefik.http.routers.gitea-secure.entrypoints=websecure

### Gitea database: PostgreSQL ###
gitea-postgresql:
image: postgres:15
container_name: gitea-postgresql
restart: always
environment:
- POSTGRES_USER=${DB_USER}
- POSTGRES_PASSWORD=${DB_PASSWORD}
- POSTGRES_DB=${DB_NAME}
- TZ=${TZ}
volumes:
- ${VOLUME_DIR}/db:/var/lib/postgresql/data

networks:
default:
name: gitea-network
traefik-network:
name: traefik-network
external: true
8 changes: 8 additions & 0 deletions services/zot/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Volume settings ##
VOLUME_DIR=

## Domain settings ##
DOMAIN=

## Timezone configuration ##
TZ=
24 changes: 24 additions & 0 deletions services/zot/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
ROOT_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SERVICE := zot
include $(ROOT_DIR)/../../core/common.mk
include .env

.ONESHELL:

.PHONY: install
install: ## Start all containers in background
@mkdir -p credentials
@touch credentials/users-credentials
@$(DOCKER_COMPOSE) up -d

.PHONY: uninstall
uninstall: ## Stop all containers and remove all data
@$(DOCKER_COMPOSE) down -v
@sudo rm -rf $(VOLUME_DIR)

.PHONY: add-user
add-user: ## Add a new user for Zot Registry
@read -p "Enter username: " username
@read -p "Enter password: " password
@echo $$(htpasswd -bBn $${username} $${password}) >> credentials/users-credentials
@$(DOCKER_COMPOSE) restart
38 changes: 38 additions & 0 deletions services/zot/config/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"distSpecVersion": "1.1.0-dev",
"storage": {
"rootDirectory": "/tmp/zot"
},
"http": {
"address": "0.0.0.0",
"port": "5000",
"auth": {
"htpasswd": {
"path": "/tmp/credentials"
}
}
},
"log": {
"level": "debug",
"output": "/tmp/logs/zot.log",
"audit": "/tmp/logs/zot-audit.log"
},
"extensions": {
"search": {
"enable": true,
"cve": {
"updateInterval": "2h"
}
},
"ui": {
"enable": true
},
"mgmt": {
"enable": true
},
"scrub": {
"enable": true,
"interval": "24h"
}
}
}
49 changes: 49 additions & 0 deletions services/zot/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
version: "3.7"

services:
### Zot: OCI-native container image registry, simplified. ###
zot:
image: ghcr.io/project-zot/zot-linux-amd64:v2.0.0-rc6
container_name: zot
restart: always
environment:
- TZ=${TZ}
volumes:
- ./config/config.json:/etc/zot/config.json:ro
- ./credentials/users-credentials:/tmp/credentials
- ${VOLUME_DIR}/data:/tmp/zot
- ${VOLUME_DIR}/logs:/tmp/logs
networks:
- default
- traefik-network
labels:
## Watchtower configuration ##
- com.centurylinklabs.watchtower.enable=true
- com.centurylinklabs.watchtower.monitor-only=true

## Diun configuration ##
- diun.enable=true

## Traefik configuration ##
# Enable Traefik #
- traefik.enable=true
- traefik.docker.network=traefik-network

# Set entrypoint port #
- traefik.http.services.zot.loadbalancer.server.port=5000

# Set HTTP domain and HTTP -> HTTPS redirection #
- traefik.http.routers.zot.rule=Host(`${DOMAIN}`)
- traefik.http.routers.zot.entrypoints=web
- traefik.http.routers.zot.middlewares=https-redirect@file

# Set HTTPS domain #
- traefik.http.routers.zot-secure.rule=Host(`${DOMAIN}`)
- traefik.http.routers.zot-secure.entrypoints=websecure

networks:
default:
name: zot-network
traefik-network:
name: traefik-network
external: true

0 comments on commit 26dcbfb

Please sign in to comment.