Skip to content

root ownership to checkout files #431

@sahay-shashank

Description

@sahay-shashank

I am facing issues in running the workflow as the files that I operate on are root owned but logged in user is a non-root.

The workflow file is as follows:

name: Go
on:
  workflow_dispatch: 
jobs:
  build:
    runs-on: self-hosted
    steps:
    - uses: actions/checkout@v4

    - name: Perform tasks inside DevContainer
      uses: devcontainers/[email protected]
      with:
        skipContainerUserIdUpdate: true
        noCache: true
        runCmd: |
          set -e
          echo "[INFO] whoami: $(whoami)"
          echo "[INFO] id (vscode): $(id vscode)"
          echo "[INFO] id (root): $(id root)"
          ls -ltrhg
          echo "[INFO] DevContainer Ready"
          echo "[INFO] Running tasks to test, generate coverage report and build"
          if ! task all; then
            echo "[ERROR] Failed to properly run the tasks"
            exit 1
          fi

The devcontainer.json is as follows:

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go .
{
	"name": "Go",
	// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
	"build": {
		"dockerfile": "Dockerfile",
		"args": {
			"VARIANT": "2-1.25-trixie"
		}
	},
	// Features to add to the dev container. More info: https://containers.dev/features.
	// "features": {},
	// Use 'forwardPorts' to make a list of ports inside the container available locally.
	// "forwardPorts": [],
	// Use 'postCreateCommand' to run commands after the container is created.
	// "postCreateCommand": "go version",
	// Configure tool-specific properties.
	// "customizations": {},
	// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
	"remoteUser": "vscode"
}

The Dockerfile that I use is as follows:

ARG VARIANT=2-1.25-trixie
FROM mcr.microsoft.com/devcontainers/go:${VARIANT}

## Copy all the scripts
#
COPY scripts/*.sh /tmp/scripts/

## Install taskfile
#
RUN bash /tmp/scripts/install_taskfile.sh
USER vscode

I have a self-hosted GitHub Runner with the following configurations:

  • rootless docker
  • rootless GitHub runner service

Referred issue: #176

Am I configuring something wrong? Please let me know if any other information is required.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions