Add actions support for 4get docker image builds #51

Closed
Fijxu wants to merge 1 commits from Fijxu/4get:master into master
Contributor

This automates the process of having to build a docker image and upload it to the registry (hub.docker.com).

It builds the docker image and it uploads it to git.lolcat.ca docker registry. You can change this to other registry like quay.io.

You will need to setup a runner in any server you have so it's able to fetch new commits, build the image and then upload it to the server. Without a runner, the job will never run.

I'll leave a small tutorial down here so you can setup a runner on the server:

  1. Install docker on the server, enable the docker service and add the user to the docker group (make sure to relogin after adding the user to the group)
  2. Download https://code.forgejo.org/forgejo/runner/releases/download/v4.0.1/forgejo-runner-4.0.1-linux-amd64 (not 5.x.x, it's broken) (and rename it to forgejo-runner xd, you can leave it inside /usr/bin if you want)
  3. Register the runner using forgejo-runner register, get the registration token from https://git.lolcat.ca/user/settings/actions/runners and set the label to: docker:docker://ghcr.io/catthehacker/ubuntu:act-22.04
  4. Keep the runner running using forgejo-runner daemon & (you can use tmux, a systemd service, whatever)
  5. Go to https://git.lolcat.ca/lolcal/4get/settings/actions/secrets and add a secret with Name USERNAME with your gitea username (lolcat) and a secret with name TOKEN, you can get the token using https://git.lolcat.ca/user/settings/applications; set a name for it, and set permissions repository: read; package: read and write
    image
  6. Copy the token generated and paste it as the token value
  7. Try it?

Every time you modify the source code, it will build a new image under git.lolcat.ca/lolcat/4get:latest, every version is going to be tagged with the date and the commit.

https://git.lolcat.ca/ckg/-/packages/container/4get/2024.11.26-1545e91

zazuwidhr

This automates the process of having to build a docker image and upload it to the registry (hub.docker.com). It builds the docker image and it uploads it to `git.lolcat.ca` docker registry. You can change this to other registry like `quay.io`. You will need to setup a `runner` in any server you have so it's able to fetch new commits, build the image and then upload it to the server. Without a runner, the job will never run. I'll leave a small tutorial down here so you can setup a runner on the server: 1. Install docker on the server, enable the docker service and add the user to the `docker` group (make sure to relogin after adding the user to the group) 2. Download https://code.forgejo.org/forgejo/runner/releases/download/v4.0.1/forgejo-runner-4.0.1-linux-amd64 (not `5.x.x`, it's broken) (and rename it to `forgejo-runner` xd, you can leave it inside /usr/bin if you want) 3. Register the runner using `forgejo-runner register`, get the registration token from https://git.lolcat.ca/user/settings/actions/runners and set the label to: `docker:docker://ghcr.io/catthehacker/ubuntu:act-22.04` 4. Keep the runner running using `forgejo-runner daemon &` (you can use tmux, a systemd service, whatever) 5. Go to https://git.lolcat.ca/lolcal/4get/settings/actions/secrets and add a secret with Name `USERNAME` with your gitea username (`lolcat`) and a secret with name `TOKEN`, you can get the token using https://git.lolcat.ca/user/settings/applications; set a name for it, and set permissions `repository: read; package: read and write` ![image](/attachments/9ceac6eb-0c52-495c-99e3-4080f3735aad) 6. Copy the token generated and paste it as the token value 7. Try it? Every time you modify the source code, it will build a new image under `git.lolcat.ca/lolcat/4get:latest`, every version is going to be tagged with the date and the commit. https://git.lolcat.ca/ckg/-/packages/container/4get/2024.11.26-1545e91 ![zazuwidhr](/attachments/e3955aeb-19d3-48db-828f-832eadf9f938)
Fijxu added 1 commit 2024-11-26 22:42:23 +00:00
Fijxu force-pushed master from 1545e91805 to 91a792d169 2024-11-26 23:11:12 +00:00 Compare
Owner

That's awesome bro, but all of this docker shit went over my head. What pushes the docker image? My machine doing git push or git itself?

That's awesome bro, but all of this docker shit went over my head. What pushes the docker image? My machine doing `git push` or git itself?
Author
Contributor

For 5 year olds: forgejo-runner calls Docker to build Dockerfile, it waits until it's finishes and then the image is pushed to the "docker registry" which is git.lolcat.ca

You can run forgejo-runner on any machine.

For 5 year olds: `forgejo-runner` calls Docker to build `Dockerfile`, it waits until it's finishes and then the image is pushed to the "docker registry" which is `git.lolcat.ca` You can run `forgejo-runner` on any machine.
Fijxu closed this pull request 2025-02-02 04:31:08 +00:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: lolcat/4get#51
No description provided.