The Gogs Project
You can find Gogs’ project details and source code at:
- The Gogs Site
- The Gogs Source Code at Github
- The Gogs Docker Container that we will use
- License: MIT ❤️
Self-Hosting Gogs
You will need just one thing, get Docker installed in your computer (or server).
Dont Think it Twice - Just Get Docker 🐋👇
You can install it for any PC/mac/Linux at home or in any cloud provider that you wish.
It will just take few moments, this one. If you are in Linux, just
apt-get update && sudo apt-get upgrade && curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
#sudo apt install docker-compose -y
And install also Docker-compose with:
apt install docker-compose -y
And when the process finishes - you can use it to SelfHost other services as well.
You should see the versions with:
docker --version
docker-compose --version
#sudo systemctl status docker #and the status
Gogs with Docker Compose
And this is the Docker Configuration file that we will use to deploy Gogs (together with a DB):
version: '3.3'
services:
postgres:
image: postgres:latest #15 #mariadb:10.7.5
container_name: postgres
restart: unless-stopped
environment:
- POSTGRES_USER=gogs
- POSTGRES_PASSWORD=p4ssw0rd
- POSTGRES_DB=gogs
ports:
- "5432:5432"
volumes:
- ./db-data:/var/lib/postgresql/data
gogs:
image: gogs/gogs:latest
container_name: gogs
restart: unless-stopped
ports:
- "3000:3000" #UI
- "10022:22"
links:
- postgres
environment:
- TZ="Europe/Prague"
volumes:
- ./gogs-data:/data
depends_on:
- postgres
If you are using Docker with CLI, just create the file with the content above and spin Gogs and the DB services with:
nano docker-compose.yml
docker compose up -d
You should see everything ready at: localhost:3000
Remember to change the DB host to postgres:5432 and include the DB password (same as you indicate in the yml file).
How to use Gogs?
Gogs and Jenkins Integration
It is possible to integrate Gogs, with Jenkins, a popular automation server used for continuous integration and delivery.
This integration allows Jenkins to automatically trigger builds when changes are pushed to a repository in Gogs.
Install and Configure Jenkins
Ensure that Jenkins is installed and running.
Install necessary plugins in Jenkins, like the Git plugin, to work with Git repositories.
Create a Jenkins Job
Create a new job in Jenkins for your project.
Configure the job to use a Git repository, providing the URL of the Gogs repository.
Set up the build triggers. Typically, you would use “Poll SCM” if you want Jenkins to periodically check for changes, or “Build when a change is pushed to Gogs” if you prefer a webhook-based approach.
Configure Webhooks in Gogs
In your Gogs repository, go to the settings and find the Webhooks section. Create a new webhook pointing to your Jenkins server. The URL usually looks like http://[jenkins-server]/gogs-webhook/?job=[job-name].
Replace [jenkins-server] with your Jenkins server address and [job-name] with the name of the job you created.
Choose which events in Gogs should trigger the webhook. Usually, this is set to “Just the push event.” Test the Integration:
Once configured, test the integration by pushing a commit to your Gogs repository. Check if the webhook triggers a new build in Jenkins as expected.
Secure the Integration (Optional but Recommended)
- Secure your webhook by using tokens or authentication methods provided by Jenkins.
- Ensure your Jenkins is secured and not publicly accessible without proper authentication.
FAQ
What are some Gogs (F/OSS) Alternatives?
- You can be interested to Self-Host Gitea
- And Also you can Self-Host Gitlab
- Or even One-Dev: Git Server + CI/CD + Kanban
How have HTTPs when using Gogs
If you are interested in using Gogs with https, deploying NGINX with Docker will be a great option for you.