feat: Set runner UID and docker GID to match github actions runner (#2077)
This is a successor to #1688 Co-authored-by: Suhas Gaddam <sgaddam@trueaccord.com>
This commit is contained in:
		
							parent
							
								
									ad1989072e
								
							
						
					
					
						commit
						ecd7531917
					
				|  | @ -12,6 +12,10 @@ ARG DUMB_INIT_VERSION=1.2.5 | ||||||
| ARG DEBUG=false | ARG DEBUG=false | ||||||
| 
 | 
 | ||||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||||
|  | 
 | ||||||
|  | # Use 1001 for compatibility with GitHub-hosted runners | ||||||
|  | ARG RUNNER_UID=1000 | ||||||
|  | 
 | ||||||
| RUN apt-get update -y \ | RUN apt-get update -y \ | ||||||
|     && apt-get install -y software-properties-common \ |     && apt-get install -y software-properties-common \ | ||||||
|     && add-apt-repository -y ppa:git-core/ppa \ |     && add-apt-repository -y ppa:git-core/ppa \ | ||||||
|  | @ -54,7 +58,7 @@ RUN apt-get update -y \ | ||||||
|     && rm -rf /var/lib/apt/lists/* |     && rm -rf /var/lib/apt/lists/* | ||||||
| 
 | 
 | ||||||
| # Runner user | # Runner user | ||||||
| RUN adduser --disabled-password --gecos "" --uid 1000 runner | RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner | ||||||
| 
 | 
 | ||||||
| ENV HOME=/home/runner | ENV HOME=/home/runner | ||||||
| 
 | 
 | ||||||
|  | @ -98,9 +102,9 @@ RUN cd "$RUNNER_ASSETS_DIR" \ | ||||||
|     && rm -f runner-container-hooks.zip |     && rm -f runner-container-hooks.zip | ||||||
| 
 | 
 | ||||||
| # Make the rootless runner directory executable | # Make the rootless runner directory executable | ||||||
| RUN mkdir /run/user/1000 \ | RUN mkdir /run/user/$RUNNER_UID \ | ||||||
|     && chown runner:runner /run/user/1000 \ |     && chown runner:runner /run/user/$RUNNER_UID \ | ||||||
|     && chmod a+x /run/user/1000 |     && chmod a+x /run/user/$RUNNER_UID | ||||||
| 
 | 
 | ||||||
| # We place the scripts in `/usr/bin` so that users who extend this image can | # We place the scripts in `/usr/bin` so that users who extend this image can | ||||||
| # override them with scripts of the same name placed in `/usr/local/bin`. | # override them with scripts of the same name placed in `/usr/local/bin`. | ||||||
|  | @ -117,8 +121,8 @@ COPY hooks /etc/arc/hooks/ | ||||||
| # Add the Python "User Script Directory" to the PATH | # Add the Python "User Script Directory" to the PATH | ||||||
| ENV PATH="${PATH}:${HOME}/.local/bin:/home/runner/bin" | ENV PATH="${PATH}:${HOME}/.local/bin:/home/runner/bin" | ||||||
| ENV ImageOS=ubuntu20 | ENV ImageOS=ubuntu20 | ||||||
| ENV DOCKER_HOST=unix:///run/user/1000/docker.sock | ENV DOCKER_HOST=unix:///run/user/$RUNNER_UID/docker.sock | ||||||
| ENV XDG_RUNTIME_DIR=/run/user/1000 | ENV XDG_RUNTIME_DIR=/run/user/$RUNNER_UID | ||||||
| 
 | 
 | ||||||
| RUN echo "PATH=${PATH}" > /etc/environment \ | RUN echo "PATH=${PATH}" > /etc/environment \ | ||||||
|     && echo "ImageOS=${ImageOS}" >> /etc/environment \ |     && echo "ImageOS=${ImageOS}" >> /etc/environment \ | ||||||
|  |  | ||||||
|  | @ -9,6 +9,10 @@ ARG DOCKER_VERSION=20.10.18 | ||||||
| ARG DOCKER_COMPOSE_VERSION=v2.6.0 | ARG DOCKER_COMPOSE_VERSION=v2.6.0 | ||||||
| ARG DUMB_INIT_VERSION=1.2.5 | ARG DUMB_INIT_VERSION=1.2.5 | ||||||
| 
 | 
 | ||||||
|  | # Use 1001 and 121 for compatibility with GitHub-hosted runners | ||||||
|  | ARG RUNNER_UID=1000 | ||||||
|  | ARG DOCKER_GID=1001 | ||||||
|  | 
 | ||||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||||
| RUN apt-get update -y \ | RUN apt-get update -y \ | ||||||
|     && apt-get install -y software-properties-common \ |     && apt-get install -y software-properties-common \ | ||||||
|  | @ -51,8 +55,8 @@ RUN apt-get update -y \ | ||||||
|     && rm -rf /var/lib/apt/lists/* |     && rm -rf /var/lib/apt/lists/* | ||||||
| 
 | 
 | ||||||
| # Runner user | # Runner user | ||||||
| RUN adduser --disabled-password --gecos "" --uid 1000 runner \ | RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \ | ||||||
|     && groupadd docker \ |     && groupadd docker --gid $DOCKER_GID \ | ||||||
|     && usermod -aG sudo runner \ |     && usermod -aG sudo runner \ | ||||||
|     && usermod -aG docker runner \ |     && usermod -aG docker runner \ | ||||||
|     && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ |     && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ | ||||||
|  |  | ||||||
|  | @ -9,6 +9,10 @@ ARG DOCKER_VERSION=20.10.18 | ||||||
| ARG DOCKER_COMPOSE_VERSION=v2.6.0 | ARG DOCKER_COMPOSE_VERSION=v2.6.0 | ||||||
| ARG DUMB_INIT_VERSION=1.2.5 | ARG DUMB_INIT_VERSION=1.2.5 | ||||||
| 
 | 
 | ||||||
|  | # Use 1001 and 121 for compatibility with GitHub-hosted runners | ||||||
|  | ARG RUNNER_UID=1000 | ||||||
|  | ARG DOCKER_GID=1001 | ||||||
|  | 
 | ||||||
| ENV DEBIAN_FRONTEND=noninteractive | ENV DEBIAN_FRONTEND=noninteractive | ||||||
| RUN apt-get update -y \ | RUN apt-get update -y \ | ||||||
|     && apt-get install -y software-properties-common \ |     && apt-get install -y software-properties-common \ | ||||||
|  | @ -46,8 +50,8 @@ RUN apt-get update -y \ | ||||||
|     && ln -sf /usr/bin/pip3 /usr/bin/pip \ |     && ln -sf /usr/bin/pip3 /usr/bin/pip \ | ||||||
|     && rm -rf /var/lib/apt/lists/* |     && rm -rf /var/lib/apt/lists/* | ||||||
| 
 | 
 | ||||||
| RUN adduser --disabled-password --gecos "" --uid 1000 runner \ | RUN adduser --disabled-password --gecos "" --uid $RUNNER_UID runner \ | ||||||
|     && groupadd docker \ |     && groupadd docker --gid $DOCKER_GID \ | ||||||
|     && usermod -aG sudo runner \ |     && usermod -aG sudo runner \ | ||||||
|     && usermod -aG docker runner \ |     && usermod -aG docker runner \ | ||||||
|     && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ |     && echo "%sudo   ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue