I’ve been trying to figure this part out for a few days. I have my own Forgejo instance and a website each running in separate containers on a Raspberry Pi. I also have the forgejo runner installed in another docker container. I followed some guides to set up forgejo actions, but all the guides end with a simple example that basically just runs the “ls” command.

I tried running ‘docker compose up’ inside my workflow, but it fails with “docker: command not found”. So how do you use the workflow to actually update the website in the other container?

I think I’d prefer keeping everything in docker but I’d be okay with making the workflow run some script on the host machine if needed.

  • WoodYouLookAtThat@lemmy.today
    link
    fedilink
    English
    arrow-up
    3
    ·
    12 minutes ago

    If you’re running forgejo runner in a docker container, it can only do things inside that container (excepting if it connects to something else). You could give that container access to the docker daemon, but at that point it’s effectively a privileged runner with root access, and I don’t think I would want to do that.

    If you install forgejo runner on the host itself and give it access to the docker daemon, it could run docker compose up, but otherwise it’s trying to use an asset that it cannot access.

    You could also feasibly have the runner SSH into the target machine and run docker commands from there.

    To me, both of these are suboptimal and I would sooner split the job into two phases:

    1. forgejo action builds
    2. gitops deploys (doco-cd, komodo, etc)
  • aislopmukbang@sh.itjust.works
    link
    fedilink
    English
    arrow-up
    2
    ·
    13 minutes ago

    if it’s running on the same machine the problem is that your forgejo container doesn’t have docker installed. Not sure if this is still best practice but back in the day we would create a docker in docker (DinD) image by installing docker and mounting the host system’s docker socket though I would expect this would take more mounts to avoid running the containers inside your forgejo container. Alternatively just install forgejo directly on the host OS. Not familiar with forgejo at all so this is all generalized advice

  • ZeroGravitas@lemmy.dbzer0.com
    link
    fedilink
    English
    arrow-up
    1
    ·
    3 minutes ago

    Not much experience with Forgejo, but for the docker compose part, you can just ssh to the host machine. Guess you’re just depending on :latest for your app, otherwise it won’t work (unless you generate your compose file). The whole script can reside in the pipeline, or in a separate repo on the host, whatever is easier.

    Use key auth for ssh and run the whole thing under a non root user that’s part of the docker group. Beware the permissions inside the Web app container too.