# \*\*\* GUIDE \*\*\*Forgejo - Powerful Self-Hosted Git Service

**URL:** <https://forum.hhf.technology/t/guide-forgejo-powerful-self-hosted-git-service/60>\
**Category:** Tutorials\
**Created:** [October 7, 2024, 5:05pm UTC](https://forum.hhf.technology/t/guide-forgejo-powerful-self-hosted-git-service/60 "2024-10-07T17:05:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hhf.technoloy](https://forum.hhf.technology/user_avatar/forum.hhf.technology/hhf.technoloy/32/68_2.png) [@hhf.technoloy](https://forum.hhf.technology/u/hhf.technoloy)\
**Post date:** [October 7, 2024, 5:05pm UTC](https://forum.hhf.technology/t/guide-forgejo-powerful-self-hosted-git-service/60/1 "2024-10-07T17:05:29Z")

</div>

### What is Forgejo?

Forgejo is a self-hosted Git service that gives developers the power to manage their projects independently, without relying on proprietary platforms. By hosting Forgejo yourself, you gain full control over your development environment, which you can customize to meet your team’s needs. Whether it’s integrating with other tools, enhancing your workflow, or ensuring the security of your software development, Forgejo provides a scalable, secure, and lightweight platform for collaboration.

Created through the joint efforts of Codeberg e.V., Forgejo is a community-driven project that champions freedom and transparency. As a fully open-source solution, it will always remain free from commercial interests. You can either create an account on an existing instance or self-host your own, giving you maximum flexibility and control. With Forgejo, developers have a solution built on the principles of security, scalability, privacy, and openness, empowering you to work together without barriers.

 ![image](https://forum-cdn.hhf.technology/original/1X/2d771a3b634b2bb6d015a374804d02d3f8d4b0d1.png)

### Key Features of Forgejo

- **Easy Setup:** Install Forgejo in just minutes using either a binary installer or Docker for greater flexibility.
- **Cross-Platform Compatibility:** Forgejo supports Windows, macOS, Linux, ARM, and more, ensuring wide accessibility.
- **Efficient Performance:** With its lightweight design, Forgejo runs smoothly on resource-constrained devices like Raspberry Pi.
- **Community-Driven:** As an open-source project, Forgejo welcomes contributions from its community, allowing users to shape its future.

* * *

### Installing Forgejo with Docker Compose

To ensure a secure installation, it’s recommended that you set up a Cloudflare tunnel or NGINX domain beforehand. Once done, you can access Forgejo’s web interface by pointing your domain to port 3000.

Below is a Docker Compose stack to help you install Forgejo on your server. If you’re new to self-hosting, be sure to check out guides on getting started. Always refer to Forgejo’s release notes for the latest version.

```yaml
version: "3"

networks:
  forgejo:
    external: false

services:
  app:
    image: codeberg.org/forgejo/forgejo:8
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - FORGEJO ____ APP_NAME=${APP_NAME}
      - FORGEJO ____ APP_SLOGAN=${APP_SLOGAN}
      - FORGEJO __database__ DB_TYPE=postgres
      - FORGEJO __database__ HOST=db:5432
      - FORGEJO __database__ NAME=${DB_NAME}
      - FORGEJO __database__ USER=${DB_USER}
      - FORGEJO __database__ PASSWD=${DB_PASSWORD}
      - FORGEJO __server__ SERVER_LANDING_PAGE=${LANDING_PAGE}
      - FORGEJO __mailer__ ENABLED=${MAILER_ENABLED}
      - FORGEJO __mailer__ FROM=${MAILER_FROM}
      - FORGEJO __mailer__ PROTOCOL=smtps
      - FORGEJO __mailer__ SMTP_ADDR=${MAILER_SMTP_ADDR}
      - FORGEJO __mailer__ SMTP_PORT=${MAILER_SMTP_PORT}
      - FORGEJO __mailer__ USER=${MAILER_USER}
      - FORGEJO __mailer__ PASSWD=${MAILER_PASSWD}
      - FORGEJO __email.incoming__ ENABLED=${EMAIL_INCOMING_ENABLED}
      - FORGEJO __email.incoming__ REPLY_TO_ADDRESS=${EMAIL_INCOMING_REPLY_TO_ADDRESS}
      - FORGEJO __email.incoming__ HOST=${EMAIL_INCOMING_HOST}
      - FORGEJO __email.incoming__ PORT=${EMAIL_INCOMING_PORT}
      - FORGEJO __email.incoming__ USERNAME=${EMAIL_INCOMING_USERNAME}
      - FORGEJO __email.incoming__ PASSWORD=${EMAIL_INCOMING_PASSWORD}
      - FORGEJO __service__ ENABLE_NOTIFY_MAIL=true
      - FORGEJO __email.incoming__ USE_TLS=${EMAIL_INCOMING_USE_TLS}
    restart: always
    networks:
      - forgejo
    volumes:
      - /docker/forgejo/forgejo:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "${PORT_HTTP}:3000"
      - "${PORT_SSH}:22"
    depends_on:
      - db
    env_file:
      - stack.env  

  db:
    image: docker.io/library/postgres:16-alpine
    restart: unless-stopped
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
      start_period: 20s
      interval: 30s
      retries: 5
      timeout: 5s
    environment:
      - POSTGRES_USER=${DB_USER}
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=${DB_NAME}
    networks:
      - forgejo
    volumes:
      - /docker/forgejo/postgres:/var/lib/postgresql/data
    env_file:
      - stack.env

```

stack.env file

```plaintext
APP_NAME=Your App Name
APP_SLOGAN=A painless, self-hosted Git service
PORT_HTTP=85
PORT_SSH=2223
DB_NAME=YourDB name
DB_USER=YoudDbUser
DB_PASSWORD=tAXGpCR5LcGrX0vF
SERVER_LANDING_PAGE=login
MAILER_ENABLED=true
MAILER_FROM=
MAILER_SMTP_ADDR=
MAILER_SMTP_PORT=465
MAILER_USER=
MAILER_PASSWD=
EMAIL_INCOMING_ENABLED=true
EMAIL_INCOMING_REPLY_TO_ADDRESS=forgejo+%{token}@hhf.technology
EMAIL_INCOMING_HOST=
EMAIL_INCOMING_PORT=993
EMAIL_INCOMING_USERNAME=
EMAIL_INCOMING_PASSWORD=
EMAIL_INCOMING_USE_TLS=true

```

**Important:** For production environments, always change the default database credentials (username and password). The example above uses default settings for simplicity, but ensure you update them before deploying your setup live.

* * *

### Completing the Installation

After setting up your Docker Compose stack, navigate to your domain to access the Forgejo installation page. Here, you’ll need to fill in the required details to complete the setup. Once you’ve submitted the form, click the “Install” button to finalize the process. After installation, you will be redirected to the main Forgejo dashboard, where you can start creating repositories, setting up organizations, and managing your Git workflow.

 ![image](https://forum-cdn.hhf.technology/original/1X/c14c56daba4c6846e55e2174e3d053d96ca40985.png)

* * *

### Final Thoughts

By choosing Forgejo, you’re not just installing another Git service—you’re joining a community that values open-source principles. Forgejo offers you the freedom to code and collaborate without restrictions. Its flexible, modular architecture allows you to adapt it to your unique workflow, and your contributions will help shape the future of the project. With Forgejo, you control your development environment while fostering transparency and collaboration.
