inital commit

This commit is contained in:
Raphael Martin 2023-11-24 18:43:23 +01:00
parent 7f312568a7
commit 8c0f7e8fb7
5 changed files with 107 additions and 1 deletions

13
.env.sample Normal file
View File

@ -0,0 +1,13 @@
MYSQL_ROOT_PASSWORD=PASSWORD
MYSQL_DATABASE=gitea
MYSQL_USER=DATABASEUSER
MYSQL_PASSWORD=DATABASEPASSWORD
PROJECT_URL=git.localhost
PROJECT_NAME=sample
TRAEFIK_NETWORK=traefik_net
PROJECT_DATA=./data

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
.env
data/*

View File

@ -1,2 +1,27 @@
# traefik_gitea
# traefik gitea
### get started
create a .env file
sample .env:
# .env
MYSQL_ROOT_PASSWORD=PASSWORD
MYSQL_DATABASE=gitea
MYSQL_USER=DATABASEUSER
MYSQL_PASSWORD=DATABASEPASSWORD
PROJECT_URL=git.localhost
PROJECT_NAME=sample
# the traefik network you want to use
TRAEFIK_NETWORK=traefik_net
# the root path to store your data from this project
PROJECT_DATA=./data
then execute the first time the init script

56
docker-compose.yml Normal file
View File

@ -0,0 +1,56 @@
version: '1'
networks:
default:
name: "${TRAEFIK_NETWORK}"
external: true
db:
name: "${PROJECT_NAME}_gitea_db_net"
external: false
services:
gitea:
image: "gitea/gitea:latest"
container_name: "${PROJECT_NAME}_gitea"
hostname: "${PROJECT_URL}"
environment:
- "USER_UID=1000"
- "USER_GID=1000"
- "GITEA__database__DB_TYPE=mysql"
- "GITEA__database__HOST=db:3306"
- "GITEA__database__NAME=${MYSQL_DATABASE}"
- "GITEA__database__USER=${MYSQL_USER}"
- "GITEA__database__PASSWD=${MYSQL_PASSWORD}"
restart: "unless-stopped"
networks:
- "db"
volumes:
- "${PROJECT_DATA}/${PROJECT_NAME}-gitea/git:/data"
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
depends_on:
- "db"
labels:
# Watchtower add to auto update
- "com.centurylinklabs.watchtower.enable=true"
# traefik
- "traefik.enable=true"
- "traefik.docker.network=${TRAEFIK_NETWORK}"
- "traefik.http.routers.${PROJECT_NAME}_gitea.rule=Host(`${PROJECT_URL}`)"
- "traefik.http.services.${PROJECT_NAME}_gitea.loadbalancer.server.port=3000"
- "traefik.http.routers.${PROJECT_NAME}_gitea.entrypoints=websecure"
- "traefik.http.routers.${PROJECT_NAME}_gitea.tls=true"
db:
image: "mariadb:latest"
container_name: "${PROJECT_NAME}_gitea_db"
restart: "unless-stopped"
env_file: ".env"
networks:
- "db"
volumes:
- "${PROJECT_DATA}/${PROJECT_NAME}-gitea/db:/var/lib/mysql"
labels:
# Watchtower add to auto update
- "com.centurylinklabs.watchtower.enable=true"
# traefik
- "traefik.enable=false"

10
init Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
source ./.env
mkdir -p ${PROJECT_DATA}/${PROJECT_NAME}-gitea/git
mkdir -p ${PROJECT_DATA}/${PROJECT_NAME}-gitea/db
docker network create $TRAEFIK_NETWORK
docker compose up -d