Volumes not being mounted in Actions containers #329

Closed
opened 2023-08-08 12:01:38 +00:00 by ghnp5 · 4 comments

I'm using gitea/act_runner:latest since it became available.

I'm having some trouble getting an extra volume mounted in the container created to run the action.

See this:

jobs:
  a_prepare:
    name: Prepare
    runs-on: ubuntu-latest
    container:
      image: docker:latest
      volumes:
        - /some-volume-path/:/some-volume-path/
    steps:
      - name: Prepare
        run: |
          ls -la /some-volume-path/

I get:

ls: /some-volume-path/: No such file or directory

--

Also, if I put in the "config.yaml",

container:
  # Specifies the network to which the container will connect.
  # Could be host, bridge or the name of a custom network.
  # If it's empty, act_runner will create a network automatically.
  network: ""
  # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker).
  privileged: false
  # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway).
  options: -v /generate-ssl-certs/:/generate-ssl-certs/
  # The parent directory of a job's working directory.
  # If it's empty, /workspace will be used.
  workdir_parent:

I get the same:

ls: /some-volume-path/: No such file or directory

--

In Portainer, these are the volumes I see mounted:

/var/run/docker.sock /var/run/docker.sock
act-toolcache /toolcache
GITEA-ACTIONS-TASK-1298_WORKFLOW-XXXXXXXX_JOB-Prepare-env /var/run/act
GITEA-ACTIONS-TASK-1298_WORKFLOW-XXXXXXXX_JOB-Prepare /workspace/myorg/actions
d5b25cf23cca3fdeccb4147dfe7c82257192849b0a9e63b2dab32398371bb419 /var/lib/docker

I'm using `gitea/act_runner:latest` since it became available. I'm having some trouble getting an extra volume mounted in the container created to run the action. See this: ``` jobs: a_prepare: name: Prepare runs-on: ubuntu-latest container: image: docker:latest volumes: - /some-volume-path/:/some-volume-path/ steps: - name: Prepare run: | ls -la /some-volume-path/ ``` I get: > ls: /some-volume-path/: No such file or directory -- Also, if I put in the "config.yaml", ``` container: # Specifies the network to which the container will connect. # Could be host, bridge or the name of a custom network. # If it's empty, act_runner will create a network automatically. network: "" # Whether to use privileged mode or not when launching task containers (privileged mode is required for Docker-in-Docker). privileged: false # And other options to be used when the container is started (eg, --add-host=my.gitea.url:host-gateway). options: -v /generate-ssl-certs/:/generate-ssl-certs/ # The parent directory of a job's working directory. # If it's empty, /workspace will be used. workdir_parent: ``` I get the same: > ls: /some-volume-path/: No such file or directory -- In Portainer, these are the volumes I see mounted: > /var/run/docker.sock /var/run/docker.sock > act-toolcache /toolcache > GITEA-ACTIONS-TASK-1298_WORKFLOW-XXXXXXXX_JOB-Prepare-env /var/run/act > GITEA-ACTIONS-TASK-1298_WORKFLOW-XXXXXXXX_JOB-Prepare /workspace/myorg/actions > d5b25cf23cca3fdeccb4147dfe7c82257192849b0a9e63b2dab32398371bb419 /var/lib/docker
Author

Aaaahhhhhhh... I've just noticed there's a new option here:

https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml

valid_volumes:
  - data
  - /src/*.json

Got it resolved now!!

Aaaahhhhhhh... I've just noticed there's a new option here: https://gitea.com/gitea/act_runner/src/branch/main/internal/pkg/config/config.example.yaml ``` valid_volumes: - data - /src/*.json ``` Got it resolved now!!
ghnp5 closed this issue 2023-08-08 12:15:49 +00:00

Hey @ghnp5

Unfortunately, I cannot reproduce your success 😥
My workflow both specifies volumes and valid_volumes like so:

[...]
container: 
      image: jvconseil/jekyll-docker:latest
      valid_volumes: 
        - '**'  # also specialized lists indicating the volumes directly  won't work
      volumes: 
        - /tmp/blog_staging:/blog_staging
        - /opt/cache:/opt/hostedtoolcache

Still, when I run the action, I get

gitea-runner-1  | [Deploy Jekyll site/build] [/tmp/blog_staging] is not a valid volume, will be ignored
gitea-runner-1  | [Deploy Jekyll site/build] [/opt/cache] is not a valid volume, will be ignored

And also ls on that folder fails, indicating that volume generation failed.

I'm using act_runner:latest.

Do you have something set in the config.yml? Anything I might have overlooked?

Thank you :)

Hey @ghnp5 Unfortunately, I cannot reproduce your success 😥 My workflow both specifies `volumes` and `valid_volumes` like so: ```yml [...] container: image: jvconseil/jekyll-docker:latest valid_volumes: - '**' # also specialized lists indicating the volumes directly won't work volumes: - /tmp/blog_staging:/blog_staging - /opt/cache:/opt/hostedtoolcache ``` Still, when I run the action, I get ``` gitea-runner-1 | [Deploy Jekyll site/build] [/tmp/blog_staging] is not a valid volume, will be ignored gitea-runner-1 | [Deploy Jekyll site/build] [/opt/cache] is not a valid volume, will be ignored ``` And also `ls` on that folder fails, indicating that volume generation failed. I'm using `act_runner:latest`. Do you have something set in the `config.yml`? Anything I might have overlooked? Thank you :)

I wasn't successful adding valid_volumes via docker-compose.yml.

Then I tried putting it into the config like so:

# gitea/runner/config.yml
  valid_volumes: ["/tmp/blog_staging", "/opt/hostedtoolcache"]

Then I had the config added as environment variable and volume so the act_runner container could access it:

# gitea/docker-compose.yml
# [...]
  runner:
    image: gitea/act_runner:latest
    environment:
      - CONFIG_FILE=/config.yml
      - GITEA_INSTANCE_URL=<redacted>
      - GITEA_RUNNER_NAME=<redacted>
      - GITEA_RUNNER_REGISTRATION_TOKEN=<redacted>
    volumes:
      - ./runner/config.yml:/config.yml
      - ./runner/data:/data
      - /opt/hostedtoolcache:/opt/hostedtoolcache
      - /var/run/docker.sock:/var/run/docker.sock

Still, it is important to have the volumes added to the runner instance - I used the action script to do so:

# .gitea/workflow/buildjekyll.yml
jobs:
  # Build job
  build:
    runs-on: ubuntu-latest # this is the "label" the runner will use and map to docker target OS
    container: 
      image: jvconseil/jekyll-docker:latest
      volumes: 
        - /opt/caddy2/www/blog:/tmp/blog_staging
        - /opt/hostedtoolcache:/opt/hostedtoolcache

This did the trick. The error message is gone and docker volume ls shows it accordingly while the action executes.

No idea why it wouldn't work in the docker-compose.yml, though.
A blog article walking through jekyll build with Gitea Actions, having artifacts saved using a volume will follow soon.

This is by far quicker for my application than using upload-artifact and download-artifact actions.

Cheers
Schallbert

I wasn't successful adding `valid_volumes` via `docker-compose.yml`. Then I tried putting it into the config like so: ```yml # gitea/runner/config.yml valid_volumes: ["/tmp/blog_staging", "/opt/hostedtoolcache"] ``` Then I had the config added as environment variable and volume so the `act_runner` container could access it: ```yml # gitea/docker-compose.yml # [...] runner: image: gitea/act_runner:latest environment: - CONFIG_FILE=/config.yml - GITEA_INSTANCE_URL=<redacted> - GITEA_RUNNER_NAME=<redacted> - GITEA_RUNNER_REGISTRATION_TOKEN=<redacted> volumes: - ./runner/config.yml:/config.yml - ./runner/data:/data - /opt/hostedtoolcache:/opt/hostedtoolcache - /var/run/docker.sock:/var/run/docker.sock ``` Still, it is important to have the volumes added to the runner instance - I used the action script to do so: ```yml # .gitea/workflow/buildjekyll.yml jobs: # Build job build: runs-on: ubuntu-latest # this is the "label" the runner will use and map to docker target OS container: image: jvconseil/jekyll-docker:latest volumes: - /opt/caddy2/www/blog:/tmp/blog_staging - /opt/hostedtoolcache:/opt/hostedtoolcache ``` This did the trick. The error message is gone and `docker volume ls` shows it accordingly while the action executes. No idea why it wouldn't work in the `docker-compose.yml`, though. [A blog article walking through jekyll build with Gitea Actions, having artifacts saved using a volume](https://schallbert.de/gitea-action-runner-jekyll-dockerimage) will follow soon. This is by far quicker for my application than using `upload-artifact` and `download-artifact` actions. Cheers _Schallbert_

BTW #407 helped me find the correct syntax (valid_volume as string, volumes as list items)

BTW #407 helped me find the correct syntax (valid_volume as string, volumes as list items)
Sign in to join this conversation.
No Milestone
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: gitea/act_runner#329
No description provided.