Run as container? #8

Closed
opened 2022-12-08 13:16:38 +00:00 by Ghost · 14 comments
  • Add a Dockerfile
  • Add a docker-compose.yml
    • mount unix:///var/run/docker.sock
  • Add a .drone.yml
    • Build and publish to Docker Hub
- [ ] Add a Dockerfile - [ ] Add a docker-compose.yml - mount ` unix:///var/run/docker.sock` - [ ] Add a `.drone.yml` - Build and publish to Docker Hub
Owner

Yes, that'll be nice.

And maybe we will use act_runner to build act_runner one day.

Yes, that'll be nice. And maybe we will use act_runner to build act_runner one day.
wolfogre added the
kind
enhancement
label 2022-12-09 04:02:30 +00:00

Instead of a .drone.yml you may use Gitea Actions, e.g. .gitea/workflows/release.yml?

Something similar to ...

name: release

on:
  workflow_dispatch:
  push:
    tags:
      - "*"

jobs:
  registries:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Get Docker metadata
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: docker.io/{username}/act_runner
          tags: |
            type=ref,event=tag
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}            
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          registry: docker.io
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile
          platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
          push: true
          labels: ${{ steps.meta.outputs.labels }}
          tags: ${{ steps.meta.outputs.tags }}
      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}
Instead of a `.drone.yml` you may use Gitea [Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/), e.g. `.gitea/workflows/release.yml`? Something similar to ... ```yml name: release on: workflow_dispatch: push: tags: - "*" jobs: registries: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - name: Get Docker metadata id: meta uses: docker/metadata-action@v4 with: images: docker.io/{username}/act_runner tags: | type=ref,event=tag type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} - name: Set up QEMU uses: docker/setup-qemu-action@v2 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Login to DockerHub uses: docker/login-action@v2 with: registry: docker.io username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push id: docker_build uses: docker/build-push-action@v3 with: context: . file: ./Dockerfile platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x push: true labels: ${{ steps.meta.outputs.labels }} tags: ${{ steps.meta.outputs.tags }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} ```

Instead of a .drone.yml you may use Gitea Actions, e.g. .gitea/workflows/release.yml?

Something similar to ...

name: release

on:
  workflow_dispatch:
  push:
    tags:
      - "*"

jobs:
  registries:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Get Docker metadata
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: docker.io/{username}/act_runner
          tags: |
            type=ref,event=tag
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}            
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          registry: docker.io
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile
          platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
          push: true
          labels: ${{ steps.meta.outputs.labels }}
          tags: ${{ steps.meta.outputs.tags }}
      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}

Hi, how to get the actions plugin from a local repo instead of https://gitea.com/actions/
?

> Instead of a `.drone.yml` you may use Gitea [Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/), e.g. `.gitea/workflows/release.yml`? > > Something similar to ... > > ```yml > name: release > > on: > workflow_dispatch: > push: > tags: > - "*" > > jobs: > registries: > runs-on: ubuntu-latest > steps: > - name: Checkout > uses: actions/checkout@v3 > - name: Get Docker metadata > id: meta > uses: docker/metadata-action@v4 > with: > images: docker.io/{username}/act_runner > tags: | > type=ref,event=tag > type=semver,pattern={{version}} > type=semver,pattern={{major}}.{{minor}} > type=semver,pattern={{major}} > - name: Set up QEMU > uses: docker/setup-qemu-action@v2 > - name: Set up Docker Buildx > uses: docker/setup-buildx-action@v2 > - name: Login to DockerHub > uses: docker/login-action@v2 > with: > registry: docker.io > username: ${{ secrets.DOCKERHUB_USERNAME }} > password: ${{ secrets.DOCKERHUB_TOKEN }} > - name: Build and push > id: docker_build > uses: docker/build-push-action@v3 > with: > context: . > file: ./Dockerfile > platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x > push: true > labels: ${{ steps.meta.outputs.labels }} > tags: ${{ steps.meta.outputs.tags }} > - name: Image digest > run: echo ${{ steps.docker_build.outputs.digest }} > ``` Hi, how to get the actions plugin from a local repo instead of https://gitea.com/actions/ ?
Owner

Instead of a .drone.yml you may use Gitea Actions, e.g. .gitea/workflows/release.yml?

Something similar to ...

name: release

on:
  workflow_dispatch:
  push:
    tags:
      - "*"

jobs:
  registries:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Get Docker metadata
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: docker.io/{username}/act_runner
          tags: |
            type=ref,event=tag
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
            type=semver,pattern={{major}}            
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v2
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          registry: docker.io
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}
      - name: Build and push
        id: docker_build
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile
          platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x
          push: true
          labels: ${{ steps.meta.outputs.labels }}
          tags: ${{ steps.meta.outputs.tags }}
      - name: Image digest
        run: echo ${{ steps.docker_build.outputs.digest }}

Hi, how to get the actions plugin from a local repo instead of https://gitea.com/actions/
?

Currently it hasn't been supported. But you can use remote action plugins.

uses: https://github.com/my_actions/my_action@v3

Any website implemented git http protocol has been supported.

> > Instead of a `.drone.yml` you may use Gitea [Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/), e.g. `.gitea/workflows/release.yml`? > > > > Something similar to ... > > > > ```yml > > name: release > > > > on: > > workflow_dispatch: > > push: > > tags: > > - "*" > > > > jobs: > > registries: > > runs-on: ubuntu-latest > > steps: > > - name: Checkout > > uses: actions/checkout@v3 > > - name: Get Docker metadata > > id: meta > > uses: docker/metadata-action@v4 > > with: > > images: docker.io/{username}/act_runner > > tags: | > > type=ref,event=tag > > type=semver,pattern={{version}} > > type=semver,pattern={{major}}.{{minor}} > > type=semver,pattern={{major}} > > - name: Set up QEMU > > uses: docker/setup-qemu-action@v2 > > - name: Set up Docker Buildx > > uses: docker/setup-buildx-action@v2 > > - name: Login to DockerHub > > uses: docker/login-action@v2 > > with: > > registry: docker.io > > username: ${{ secrets.DOCKERHUB_USERNAME }} > > password: ${{ secrets.DOCKERHUB_TOKEN }} > > - name: Build and push > > id: docker_build > > uses: docker/build-push-action@v3 > > with: > > context: . > > file: ./Dockerfile > > platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le,linux/s390x > > push: true > > labels: ${{ steps.meta.outputs.labels }} > > tags: ${{ steps.meta.outputs.tags }} > > - name: Image digest > > run: echo ${{ steps.docker_build.outputs.digest }} > > ``` > > Hi, how to get the actions plugin from a local repo instead of https://gitea.com/actions/ > ? > Currently it hasn't been supported. But you can use remote action plugins. ``` uses: https://github.com/my_actions/my_action@v3 ``` Any website implemented git http protocol has been supported.

Are there any docker images for act_runner yet? If not, I just created one that is successfully running on my local machine and connecting to my self hosted gitea.
If there are no images yet, my goal would also be to build a helm chart with dind approach.

Are there any docker images for act_runner yet? If not, I just created one that is successfully running on my local machine and connecting to my self hosted gitea. If there are no images yet, my goal would also be to build a helm chart with dind approach.
Owner

Are there any docker images for act_runner yet? If not, I just created one that is successfully running on my local machine and connecting to my self hosted gitea.
If there are no images yet, my goal would also be to build a helm chart with dind approach.

There are no official binaries and images yet, because we are waiting https://github.com/go-gitea/gitea/pull/22803 merge so that we can begin building act_runner official binaries and images via act_runner.

> Are there any docker images for act_runner yet? If not, I just created one that is successfully running on my local machine and connecting to my self hosted gitea. > If there are no images yet, my goal would also be to build a helm chart with dind approach. There are no official binaries and images yet, because we are waiting https://github.com/go-gitea/gitea/pull/22803 merge so that we can begin building `act_runner` official binaries and images via `act_runner`.

Official binaries are now in https://dl.gitea.com/act_runner/ . So how does one create official docker/OCI images from those?

Official binaries are now in https://dl.gitea.com/act_runner/ . So how does one create official docker/OCI images from those?
Owner

Official binaries are now in https://dl.gitea.com/act_runner/ . So how does one create official docker/OCI images from those?

Some PRs want to fix it.

> Official binaries are now in https://dl.gitea.com/act_runner/ . So how does one create official docker/OCI images from those? Some PRs want to fix it.

@ptman you can give this a try in the meantime https://github.com/vegardit/docker-gitea-act-runner

@ptman you can give this a try in the meantime https://github.com/vegardit/docker-gitea-act-runner
Contributor

I opened #84 as a simple proposal, which includes:

a) A very simple Dockerfile for act_runner.

b) A second Dockerfile for a task executor that has Docker and NodeJS.

c) Sets TaskInput.privileged=true

Taken together allows for running act_runner as a container, which executes its tasks by launching containers which themselves support Docker-in-Docker, allowing for the use of docker run, docker compose, etc. inside workflows*.

The process would be something like:

NOTE: I used the same ENV names as the above mentioned project, for consistency.


> docker build . -t act_runner:local

> docker build . -t act_runner-task-executor:local -f Dockerfile.task-executor

> cat >> act_runner.env <<EOF
GITEA_RUNNER_REGISTRATION_TOKEN=MY_TOKEN_GOES_HERE
GITEA_INSTANCE_URL=http://my.gitea.url:3000
GITEA_RUNNER_LABELS=ubuntu-latest:docker://act_runner-task-executor:local
EOF

> docker run -d -v `pwd`/data:/data --env-file act_runner.env -v /var/run/docker.sock:/var/run/docker.sock act_runner:local

  • While you could use docker run/compose inside workflows without dind by accessing /var/run/docker.sock on the host, there would be no way to guarantee cleanup, especially if tasks failed. In contrast, with dind, when the parent task container is destroyed by act_runner, any child containers will go with it.
I opened https://gitea.com/gitea/act_runner/pulls/84 as a simple proposal, which includes: a) A very simple Dockerfile for act_runner. b) A second Dockerfile for a task executor that has Docker and NodeJS. c) Sets `TaskInput.privileged=true` Taken together allows for running `act_runner` as a container, which executes its tasks by launching containers which themselves support Docker-in-Docker, allowing for the use of `docker run`, `docker compose`, etc. inside workflows*. The process would be something like: > NOTE: I used the same ENV names as the above mentioned project, for consistency. ``` > docker build . -t act_runner:local > docker build . -t act_runner-task-executor:local -f Dockerfile.task-executor > cat >> act_runner.env <<EOF GITEA_RUNNER_REGISTRATION_TOKEN=MY_TOKEN_GOES_HERE GITEA_INSTANCE_URL=http://my.gitea.url:3000 GITEA_RUNNER_LABELS=ubuntu-latest:docker://act_runner-task-executor:local EOF > docker run -d -v `pwd`/data:/data --env-file act_runner.env -v /var/run/docker.sock:/var/run/docker.sock act_runner:local ``` * While you could use `docker run/compose` inside workflows without dind by accessing `/var/run/docker.sock` on the host, there would be no way to guarantee cleanup, especially if tasks failed. In contrast, with dind, when the parent task container is destroyed by act_runner, any child containers will go with it.
Owner

Closed by #84

Closed by #84

@jokay
Regarding your example, I'm curious what image labels you are using for your runners?

I'm using the github.com/catthehacker/ docker images and have only been able to build container images targeted for the linux/amd64 and linux/arm64 platforms.

Opened an issue about it, but have yet to hear anything back.

@jokay Regarding [your example](https://gitea.com/gitea/act_runner/issues/8#issuecomment-724971), I'm curious what image labels you are using for your runners? I'm using the [github.com/catthehacker/ docker images](https://github.com/catthehacker/docker_images/) and have only been able to build container images targeted for the `linux/amd64` and `linux/arm64` platforms. Opened [an issue](https://github.com/catthehacker/docker_images/issues/112) about it, but have yet to hear anything back.

@jokay
Regarding your example, I'm curious what image labels you are using for your runners?

Well it's only a sample (not used in production).

I'm currently still using GitLab on amd64 and a GitLab Runner(s) on arm64.

I would like to use Gitea instead of GitLab one day to have a less bloated experience running smootly on a RasperryPi setup 😉 but didn't have time to migrate all the workflow to Gitea Actions yet.

> @jokay > Regarding [your example](https://gitea.com/gitea/act_runner/issues/8#issuecomment-724971), I'm curious what image labels you are using for your runners? Well it's only a sample *(not used in production)*. I'm currently still using GitLab on **amd64** and a GitLab Runner(s) on **arm64**. I would like to use Gitea instead of GitLab one day to have a less bloated experience running smootly on a RasperryPi setup :wink: but didn't have time to migrate all the workflow to Gitea Actions yet.

currently still using GitLab

Same.. well, straddled between the two and haven't fully committed 😅
(pending finding a solution to these cross-platform builds.. might need a custom runner)

didn't have time to migrate all the workflow to Gitea Actions yet

Once you have a good process for the first couple, I imagine the rest will go a lot quicker 👍

> currently still using GitLab Same.. well, straddled between the two and haven't fully committed 😅 _(pending finding a solution to these cross-platform builds.. might need a custom runner)_ > didn't have time to migrate all the workflow to Gitea Actions yet Once you have a good process for the first couple, I imagine the rest will go a lot quicker 👍
Sign in to join this conversation.
No Milestone
No Assignees
10 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: gitea/act_runner#8
No description provided.