Skip to content
Go back

Forgejo Packages: Docker and npm Registry

By KingPin 13 min read
Contents

You Already Run the Registry. You Just Haven’t Turned It On

You self-host Forgejo for your git repos. Then you want a private Docker registry, so you read about Harbor. Then you want private npm packages, so you read about Verdaccio. Now your plan is three stacks, three databases, and three sets of credentials, to host a few dozen images and four internal libraries.

Skip that. Forgejo has a built-in package registry that speaks the OCI container protocol and the npm protocol, and it supports more than 20 other formats too. It runs inside the Forgejo process you already back up and already put behind a reverse proxy. For a home lab or a small team, it is enough. Harbor and Verdaccio earn their place only when you need specific features, and I will list those near the end.

This post uses Forgejo 17 (the current stable line, 17.0.2, released 2026-11-18) and walks through both registries on one instance.

Full example: Clone the working files at github.com/KingPin/sumguy-examples/self-hosting/forgejo-packages-registry

What Forgejo Packages Actually Gives You

A package belongs to an owner, meaning a user or an organization. You can link a package to a repo afterward so it shows up in the repo’s Packages tab, but the owner still controls access.

Access follows the owner:

Owner typeReadWrite
UserPublic if the user is public, otherwise that user onlyOwner only
OrganizationPublic if the org is public, otherwise org members onlyOrg members with admin or write access

Two more rules from the docs. Setting service.REQUIRE_SIGNIN_VIEW locks public access instance-wide. And the docs warn that this permission model may change, with a finer-grained team permission planned. There is no per-image visibility toggle today, so a private image means a private owner.

Practical consequence: if you want a public image and a private image, put them under different owners, for example a public homelab-public org and a private homelab org.

Turning It On

The registry is enabled by default. The [packages] section of app.ini has ENABLED: true out of the box. You only touch config to set limits, and you should, because the defaults are no limits at all (-1).

Here is a compose file with those limits set through environment variables. Forgejo’s Docker image maps FORGEJO__section__KEY to app.ini entries.

docker-compose.yml
services:
forgejo:
image: codeberg.org/forgejo/forgejo:17
container_name: forgejo
restart: always
environment:
- USER_UID=1000
- USER_GID=1000
- FORGEJO__packages__LIMIT_TOTAL_OWNER_SIZE=20 GiB
- FORGEJO__packages__LIMIT_SIZE_CONTAINER=2 GiB
- FORGEJO__packages__LIMIT_SIZE_NPM=100 MB
volumes:
- ./forgejo:/data
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "222:22"

The same thing in app.ini:

app.ini
[packages]
ENABLED = true
LIMIT_TOTAL_OWNER_SIZE = 20 GiB
LIMIT_SIZE_CONTAINER = 2 GiB
LIMIT_SIZE_NPM = 100 MB

Each key does one job:

A runaway CI loop that pushes a 900 MB image on every commit is a real thing that happens. A cap turns it into a failed job instead of a full disk.

The Reverse Proxy Gotcha

Docker pushes upload layers as large request bodies. nginx rejects bodies over 1 MB by default and answers with a 413, which shows up in Docker as a failed layer upload. Forgejo’s own nginx example sets client_max_body_size 512M; inside the location / block. Copy that:

forgejo.conf
server {
listen 443 ssl;
server_name forgejo.example.com;
location / {
client_max_body_size 512M;
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

If one of your layers is bigger than 512 MB (a CUDA base image, say), raise the number.

Container Registry: Login, Tag, Push, Pull

Images are named {registry}/{owner}/{image}:{tag}, where the registry is just the hostname of your Forgejo. Nested names like forgejo.example.com/alice/my/image are valid too.

First, make a token. In your Forgejo user settings, under Applications, create an access token with the write:package scope. The docs say write:package grants read, write, and delete on package operations and is currently the same as read:package. If you use 2FA or OAuth login, you must use a token as the password anyway.

Terminal window
docker login forgejo.example.com
# Username: alice
# Password: <paste the access token>
docker build -t forgejo.example.com/alice/webapp:1.0 .
docker push forgejo.example.com/alice/webapp:1.0
# on any other machine
docker login forgejo.example.com
docker pull forgejo.example.com/alice/webapp:1.0

Two quirks worth knowing:

  1. Tag names are case-insensitive. webapp:Beta and webapp:beta are the same tag.
  2. A public owner means anyone can pull without logging in. A private owner means every host that pulls needs a login.

Linking an Image to a Repo

By default the image sits under your user or org page and not in any repo’s Packages tab. Forgejo links an image to a repo automatically on first creation, in two ways. Label the image:

Dockerfile
LABEL org.opencontainers.image.source=https://forgejo.example.com/alice/webapp

Or name the image after the repository, as in forgejo.example.com/alice/webapp. If both match, the label wins. The catch: auto-linking happens only when the package is first created. New tags on an existing image never re-link it. If you missed the window, open the package’s Settings page and pick the repo manually. That links the whole package, not one version.

Building and Pushing From Forgejo Actions

Here is the workflow most people want: push to main, runner builds the image, image lands in your registry. I am using a personal access token stored as a repository secret. The CI example in Forgejo’s npm docs carries a comment telling you not to use the automatic FORGEJO_TOKEN secret and to use the owner’s token instead. The container docs do not make a promise either way about the automatic token, so I do not rely on it and neither should you.

Create a secret named REGISTRY_TOKEN in the repo settings, holding a token with write:package. The job needs a runner with a Docker CLI, such as the ci label from the runner setup post.

.forgejo/workflows/image.yml
name: Build and push image
on:
push:
branches: [main]
jobs:
image:
runs-on: ci
steps:
- uses: actions/checkout@v6
- name: Log in to the Forgejo registry
run: |
echo "${{ secrets.REGISTRY_TOKEN }}" | \
docker login forgejo.example.com -u alice --password-stdin
- name: Build and push
run: |
IMAGE=forgejo.example.com/alice/webapp
docker build -t "$IMAGE:${{ github.sha }}" -t "$IMAGE:latest" .
docker push "$IMAGE:${{ github.sha }}"
docker push "$IMAGE:latest"

Tagging with the commit SHA gives you a rollback target. latest is for humans.

npm Registry: Private Packages

Now the second half. The registry URL for an owner is https://forgejo.example.com/api/packages/{owner}/npm/. It supports scoped and unscoped packages, and works with npm, yarn, and pnpm.

Use a scope. Point the scope at Forgejo and leave everything else on npmjs. Put this in a project-level .npmrc:

.npmrc
@homelab:registry=https://forgejo.example.com/api/packages/homelab/npm/
//forgejo.example.com/api/packages/homelab/npm/:_authToken=${FORGEJO_NPM_TOKEN}

Look at the second line. It has no https: in front. npm auth entries are keyed by a bare URI fragment, and with the scheme added npm never matches the token to the registry. The Forgejo docs call this out specifically. In my test on npm 11, the https: version made npm publish fail with ENEEDAUTH and a suggestion to run npm adduser, which sends you looking in the wrong place.

Export the token in your shell (a personal access token with write:package, belonging to a user who can write to the homelab org), and keep it out of the committed file:

Terminal window
export FORGEJO_NPM_TOKEN="<your access token>"

The package name must carry the scope:

package.json
{
"name": "@homelab/utils",
"version": "1.0.0",
"main": "index.js"
}

Publish and install:

Terminal window
npm publish
# in another project that has the same .npmrc scope lines
npm install @homelab/utils

A few behaviors that differ from npmjs:

For CI publishing, the docs example sets npm config set for the scope and token, then runs npm publish --scope=@homelab --registry=..., with the owner’s token in a secret. Same pattern as the image workflow above.

Cleanup Rules, Before the Disk Fills

Registries grow forever unless you stop them. Each owner manages cleanup rules for their own packages: go to the owner’s (user or org) settings and find the package cleanup rules. A rule targets one package type, so you make one rule for Container and one for npm.

The settings:

Patterns are anchored and case-insensitive. Do not write ^ or $. The container registry always keeps the latest version regardless.

A sane home lab rule for images: keep the 10 most recent, keep versions matching latest|v.+, remove versions older than 30 days. Because every commit-SHA tag you push is a version, this prunes the CI litter while leaving your release tags alone. Use the preview button before you enable it. A rule with a wrong regex and no preview is how you delete a production image on a Friday.

Deleting a version does not free disk immediately. Forgejo deduplicates blobs, and a delete only drops the references. A background cleanup job removes unreferenced blobs after the OLDER_THAN period passes, so your disk usage drops a bit after your rules run, not during.

When Forgejo Packages Is Enough

Stay on Forgejo Packages when:

That covers most home labs. A Harbor install is a forklift: great if you move pallets, silly if you move one couch a year. The Harbor post shows how much stack you sign up for.

When to Reach for Harbor

Move your images to Harbor when you need things I could not find in Forgejo’s package docs:

Notice that none of these is about pushing and pulling images. If you cannot name one of the four bullets you need, you do not need Harbor yet. Forgejo and Harbor can run side by side, so migrating later is a docker pull and docker push per image.

When to Reach for Verdaccio

Verdaccio’s selling feature is uplinks. You configure it with uplinks: pointing at https://registry.npmjs.org/, and it proxies and caches public packages, so installs work faster and keep working when npmjs hiccups. Forgejo’s npm registry is a place to publish your own packages. It is not a caching proxy for the public registry.

So the split is simple. Private internal packages only: Forgejo. Faster CI installs through a cache of public packages, or one registry URL that serves both: Verdaccio.

Gotchas Worth Writing Down

  1. Wrong token scope. The login or push is denied and the Docker client prints something unhelpful. Check that the token has write:package and that the user can write to the owner.
  2. HTTPS and the proxy body limit. Covered above. If pushing a small image works and a large one fails, it is the body limit.
  3. Permissions follow the owner. If a CI user cannot push to an org’s package, check org membership and whether the team has write access.
  4. Backups. Package blobs live on the filesystem and metadata lives in the database. Your normal Forgejo backup covers packages only if it covers both, and Docker images are large, so size your backup target for them.

Common Questions

Does Forgejo have a built-in Docker registry?

Yes. Forgejo includes an OCI-compliant container registry in the same process as git hosting, enabled by default. You log in with docker login forgejo.example.com and push images named forgejo.example.com/{owner}/{image}:{tag}. No extra service is required.

Can I make a single Forgejo image private and others public?

No, not per image. Package access follows the owner: a public user or org exposes its packages publicly, and a private one restricts them. To mix both, put public images under one owner and private images under another, such as two separate organizations. The Forgejo docs note finer-grained team permissions are planned but not available.

Why does docker push fail with a 413 on large images?

The reverse proxy is rejecting the layer upload as too large. nginx limits request bodies to 1 MB unless you raise client_max_body_size. Forgejo’s own nginx example sets 512M inside the location / block. Set it above your biggest layer, reload nginx, and retry the push. Small images succeed while large ones fail, which is the telltale sign. Check the proxy’s error log for the 413 to confirm.

Can I move images from Docker Hub or Gitea to Forgejo?

Yes. For each image, run docker pull from the old registry, docker tag it with the new forgejo.example.com/{owner}/{image}:{tag} name, and docker push it. Nothing converts automatically. A short shell loop over your image list handles dozens of images in minutes.

Do I need Harbor or Verdaccio if I use Forgejo Packages?

Not for a home lab. Forgejo Packages covers push, pull, tags, access control by owner, and cleanup rules for both containers and npm. Add Harbor only for vulnerability scanning, replication, proxy cache, or many scoped robot accounts. Add Verdaccio only when you want a caching proxy for public npm packages. Without one of those needs, the extra stacks are overhead.


Share this post on:

Send a Webmention

Written about this post on your own site? Send a webmention and it'll show up above once verified.


Next Post
OpenWrt as a Dumb Access Point

Discussion

Powered by Garrul . Sign in with GitHub or Google, or post anonymously.

Related Posts