# Introduction In this repo I am documenting how to setup your own selfhosted git platform complete with CI/CD using forgejo. # Steps: 1. Setup folder 2. customize `compose.yml` # Setup folder In your appdata folder create new folder called `forgejo`. In my case it's `~/apps/forgejo`. `cd` into the forgejo folder and create a `compose.yml` using your editor of choice. In my case it's `vim compose.yml`. Paste the contents of the `compose.yml` file in this repository. Copy the contents of the `.env.sample` inside this repo into the folder and rename it to `.env`. Random string `openssl rand -hex 20` # Edit `compose.yml` The docker compose file is setup for forgejo to be used with a reverse-proxy, which if you want to use it from outside your home network, I strongly suggest. It expects to be run with a network called `proxy`. If your network is called differently you have to change the file accordingly. # Initial startup Run `docker-compose up -d && docker-compose logs -f` in order to follow the initial startup process. The first startup will create your administrative user according to the `ADMIN_USERNAME`, `ADMIN_PASSWORD` and `ADMIN_EMAIL` variables you set in the `.env` file. Furthermore a ci-runner will be registered to your forgejo instance through the `runner-register` container and the `command` inside the forgejo container. After about 20 seconds you can stop following the logs with `ctrl+c`. Afterwards stop the stack by running `docker-compose down`. # Cleanup `compose.yml` After the initial startup is completed you have to make some changes to the `compose.yml`. The first startup handled the creation of your admin user and the registration of the ci-runner. These sections are not needed anymore. 1. Remove the `command` section from the `forgejo` container. 2. Remove the `runner-register` container definition from the compose file. # Configure Forgejo After cleaning up the `compose.yml` file you can now configure forgejo. The data for the `forgejo` container is stored in the `app` folder. Using your editor of choice you can edit the `app/gitea/conf/app.ini` file. Inside the `app.ini` there are some things you have to change and also some you can change if you like to, starting with the `APP_NAME`. Inside the `[server]` section you have to change the `ROOT_URL` for forgejo to work properly generating URLs like clone URLs etc. Change it to your domain and subdomain combination like `https://forgejo.mydomain.com`. Optionally, if you plan to use your forgejo instance as a package registry for example for docker container images, you can change the ini file and add the following: ```ini [packages] ENABLED = true ``` Lastly I would suggest to change the default source for runner containers in the ini file to `https://github.com` as there a way more available predefined actions. Browse them in in the [actions]("https://github.com/marketplace?type=actions") section of the github marketplace ```ini [actions] DEFAULT_ACTIONS_URL = https://github.com ``` # Final word Congratulations! Your forgejo instance is now up and running, all together with a CI/CD pipeline runner.