├── .env.dist ├── .gitignore ├── README.md ├── docker-compose.yml ├── docker-gitea.service.dist └── volumes └── .gitkeep /.env.dist: -------------------------------------------------------------------------------- 1 | GITEA_VERSION=latest 2 | GITEA_HOSTNAME=localhost 3 | GITEA_WEB_PORT=3000 4 | GITEA_SSH_PORT=2222 5 | MYSQL_ROOT_PASSWORD=root 6 | MYSQL_DATABASE=gitea 7 | MYSQL_USER=gitea 8 | MYSQL_PASSWORD=gitea -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | .env 3 | volumes/gitea* 4 | docker-gitea.service 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker-Compose-Gitea 2 | 3 | A Docker Compose file for Gitea - Git with a cup of tea ([gitea.io](https://gitea.io)) 4 | 5 | Data will be saved in separate docker volumes to enable easy upgrades! 6 | 7 | ## Requirements 8 | 9 | * docker 10 | * docker-compose 11 | 12 | ## Getting Started 13 | 14 | 1. Copy **.env.dist** to **.env** and make your modifications 15 | 2. Start docker containers: 16 | ``` 17 | $ docker-compose up -d 18 | ``` 19 | 20 | After that open gitea installer via browser: [http://localhost:3000](http://localhost:3000) and fill the form according your .env settings. 21 | 22 | Set **`gitea-db:3306`** in _Host_ field and complete setup. 23 | 24 | After setup is completed register a new user (use link from the navigation bar). 25 | 26 | The first registered user has admin privileges. 27 | 28 | 29 | ### Environment Configuration 30 | 31 | | VARIABLE | Description | DEFAULT | 32 | | ----------------------|-----------------------------------|:-------------:| 33 | |GITEA_VERSION | Docker-Image-Version |latest | 34 | |GITEA_HOSTNAME | Hostname for Gitea Application |localhost | 35 | |GITEA_WEB_PORT | GUI-Port for accessing Gitea |3000 | 36 | |GITEA_SSH_PORT | Port for accessing Gitea via SSH |2222 | 37 | |MYSQL_ROOT_PASSWORD | MySQL root password |root | 38 | |MYSQL_DATABASE | Database name for gitea |gitea | 39 | |MYSQL_USER | Database user for gitea |gitea | 40 | |MYSQL_PASSWORD | Password for MySQL user |gitea | 41 | 42 | 43 | ## Create systemd unit 44 | 1. Copy **docker-gitea.service.dist** to **docker-gitea.service** 45 | 1. Adjust **WorkingDirectory** in service file if needed 46 | 1. Create symbolic link: ``ln -s docker-gitea.service /etc/systemd/system/docker-gitea.service`` 47 | 1. Start service: ``systemctl start docker-gitea`` 48 | 1. (optional) Enable autostart at boot: ``systemctl enable docker-gitea`` 49 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | volumes: 3 | app: 4 | db: 5 | services: 6 | app: 7 | container_name: gitea-app 8 | restart: always 9 | image: gitea/gitea:${GITEA_VERSION} 10 | links: 11 | - db:mysql 12 | volumes: 13 | - ./volumes/gitea_app:/data 14 | ports: 15 | - "${GITEA_SSH_PORT}:22" 16 | - "${GITEA_WEB_PORT}:3000" 17 | environment: 18 | - VIRTUAL_PORT=3000 19 | - VIRTUAL_HOST=${GITEA_HOSTNAME} 20 | networks: 21 | - backend 22 | - frontend 23 | db: 24 | container_name: gitea-db 25 | restart: always 26 | image: mysql:8.0 27 | #security_opt: 28 | # - seccomp:unconfined 29 | cap_add: [ SYS_NICE ] 30 | volumes: 31 | - ./volumes/gitea_db:/var/lib/mysql 32 | environment: 33 | - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} 34 | - MYSQL_DATABASE=${MYSQL_DATABASE} 35 | - MYSQL_USER=${MYSQL_USER} 36 | - MYSQL_PASSWORD=${MYSQL_PASSWORD} 37 | networks: 38 | - backend 39 | 40 | networks: 41 | frontend: 42 | backend: 43 | -------------------------------------------------------------------------------- /docker-gitea.service.dist: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=docker-gitea 3 | Requires=docker.service 4 | After=docker.service 5 | 6 | [Service] 7 | Restart=always 8 | 9 | WorkingDirectory=/opt/docker-compose-gitea/ 10 | 11 | # Remove old containers, images and volumes 12 | ExecStartPre=/usr/local/bin/docker-compose down -v 13 | ExecStartPre=/usr/local/bin/docker-compose rm -v 14 | 15 | # Compose up 16 | ExecStart=/usr/local/bin/docker-compose up 17 | 18 | # Compose down, remove containers and volumes 19 | ExecStop=/usr/local/bin/docker-compose down -v 20 | 21 | [Install] 22 | WantedBy=multi-user.target 23 | -------------------------------------------------------------------------------- /volumes/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sguter90/docker-compose-gitea/f8511d9b102faaa63831feecc84bdb69e60120fe/volumes/.gitkeep --------------------------------------------------------------------------------