--- title: How to Install Forgejo with Docker and Migrate from GitHub lang: en published: 2024-09-07T06:12:40.076Z description: Set up Forgejo with Docker as a self-hosted alternative to GitHub. This guide will show you how to install Forgejo and migrate your GitHub repositories. image: "" tags: - GitHub - Forgejo - Docker category: Software Engineering draft: false --- # How to Install Forgejo with Docker and Migrate from GitHub Learn how to set up Forgejo with Docker and move your code from GitHub. This simple guide makes switching to a self-hosted platform easy. ## Docker Create a new folder named forgejo: ```bash mkdir ~/docker cd ~/docker mkdir forgejo ``` Create docker-compose.yml: ```bash nano docker-compose.yml ``` Modify docker-compose.yml and save the changes: ```yaml version: '3' networks: forgejo: external: false services: server: image: codeberg.org/forgejo/forgejo:7 container_name: forgejo environment: - USER_UID=1000 - USER_GID=1000 restart: always networks: - forgejo volumes: - ./forgejo:/data - /etc/timezone:/etc/timezone:ro - /etc/localtime:/etc/localtime:ro ports: - '3000:3000' - '222:22' ``` >[!NOTE] >Check the official Forgejo website for the latest docker-compose file to install the most recent version. *(Retrieved from [Forgejo documentation](https://forgejo.org/docs/latest/admin/installation-docker/) on September 6, 2024)* Port 3000 is commonly used for web servers. Use a different port to avoid conflicts with other web servers. Change port from `3000:3000` to `3003:3003` in docker-compose.yml. Start Docker: ```bash docker compose up -d ``` Check if containers are running properly: ```bash docker compose ps ``` Go to Forgejo configuration page at http://example.com:3000 and create your account. To reduce RAM usage, set the database type to SQLite and disable self-registration. Then, save the configuration. Open Forgejo configuration file: ```bash nano forgejo/gitea/conf/app.ini ``` Set `DISABLE_REGISTRATION` to `true`, and add `ENABLE_REVERSE_PROXY_AUTHENTICATION = true` in the [service] section and `LANDING_PAGE = explore` in the [server] section: ```ini DISABLE_REGISTRATION = true [service] ENABLE_REVERSE_PROXY_AUTHENTICATION = true [server] LANDING_PAGE = explore ``` The `LANDING_PAGE` setting decides what users see when they go to the home page. It can be set to `home`, `explore`, `organizations`, `login` or custom URL /custom or https://example.com/custom. *(Retrieved from [Forgejo documentation](https://forgejo.org/docs/latest/admin/config-cheat-sheet/) on September 6, 2024)* Restart Docker: ```bash docker compose down; docker compose up -d ``` ## Reverse Proxy Install Caddy: ```bash sudo apt install caddy ``` Open Caddyfile: ```bash sudo nano /etc/caddy/Caddyfile ``` Update Caddyfile: ``` example.com { route /git* { uri strip_prefix /git redir https://git.{host}{uri} } } git.example.com { reverse_proxy localhost:3003 } ``` Restart Caddy: ```bash sudo systemctl restart caddy ``` Go to Forgejo at https://git.example.com or at https://example.com/git if you prefer using a subpath. ## Migrate Repositories from GitHub 1. Create an access token in GitHub settings. This [GitHub documentation](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) provides a step-by-step guide on how to create the token. 2. Log in to Forgejo. 3. Click the plus sign (+) in the upper right corner and select **New Migration**. 4. Enter GitHub repository URL and your access token, then click **Migrate Repository** button.