1

I'm trying to mount a dir from the app container (image is built in another job to cache and then downloaded) to host (GHA self-hosted worker) to get files created by the app during tests.

The setup is following:

action for spinning up my containers:

name: Prepare backend
description: Prepare and start docker compose for backend
inputs:
  ...
runs:
  using: composite
  steps:
    - name: Download back
      uses: actions/download-artifact@v2
      with:
        name: app-back
        path: /tmp

    - name: Load Docker image
      shell: bash
      run: |
        docker load --input /tmp/app-back.tar

    - name: Create export dir
      shell: bash
      run: mkdir /tmp/export

    - name: Start Compose
      shell: bash
      env:
      run: docker compose -f ./ci/docker-compose-ci.yml up -d

    - name: Wait Compose
      shell: bash
      run: |
        pip install docker-compose-wait
        docker-compose-wait -f ./ci/docker-compose-ci.yml -w -t 7m
        docker inspect app-back  # debugging to see actual mounts

docker-compose-ci.yml

version: '3.3'

services:
  ...

  back:
    image: app-back
    environment:
      ...
    volumes:
      - /tmp/export:/tmp/export

  # other containers for app env
  ...

workflow.yml

jobs:
  ...

  tests:
    name: Run tests
    runs-on: [ self-hosted, default ]
    needs:
      - build-app-image
    steps:
      - name: Setup Environment
        uses: actions/checkout@v2

      - name: Start backend
        uses: ./ci/actions/prepare-back

      - name: Run tests
        run: tox -e ci

      - name: Stop Compose
        if: ${{ always() }}
        run: docker compose -f ./ci/docker-compose-ci.yml down

The directory in host is created before compose start and I see it's there during test run, the directory in container is also there and I see files are created in container's logs, but host's directory is empty anyway. I tried adding chmod 777 /tmp/export at host but it didn't help.

Docker inspect also shows that the directory is mounted:

        "Mounts": [
            ***
                "Type": "bind",
                "Source": "/tmp/export",
                "Destination": "/tmp/export",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            ***
        ],

Am I missing something?

  • Could you please create an [MCVE](https://meta.stackoverflow.com/questions/366988/what-does-mcve-mean) for this and share its link? That would make it easier to reproduce and iterate. – Azeem Mar 15 '23 at 17:01

0 Answers0