Skip to content

Commit

Permalink
fix - adjust docker permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
chaddyc committed Jan 1, 2025
1 parent 6d3f136 commit 4f2d513
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ RUN useradd -m -s /bin/bash runner && \
echo "runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

# Create the docker group and add the runner user
RUN getent group docker || groupadd -g 999 docker && \
RUN getent group docker || groupadd -g 988 docker && \
usermod -aG docker runner

RUN chown -R runner:runner /runner

# Copy scripts
COPY dockerd-entrypoint.sh /usr/local/bin/dockerd-entrypoint.sh
RUN chmod +x /usr/local/bin/dockerd-entrypoint.sh

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

USER runner
WORKDIR /runner

# Start Docker daemon in the container
RUN mkdir -p /home/runner/.docker && chmod -R 0700 /home/runner/.docker
CMD ["dockerd-entrypoint.sh"]

ENTRYPOINT ["/entrypoint.sh"]
15 changes: 15 additions & 0 deletions dockerd-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

# If the first argument is `dockerd`, run the Docker daemon
if [ "$1" = "dockerd" ]; then
# Create necessary directories
mkdir -p /var/lib/docker
mkdir -p /etc/docker

# Start the Docker daemon
exec "$@" --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375
fi

# If the command is not `dockerd`, execute it
exec "$@"
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ if [ -z "$GITHUB_URL" ] || [ -z "$RUNNER_TOKEN" ]; then
exit 1
fi

# sudo groupadd -g 121 runner
# sudo useradd -mr -d /home/runner -u 1001 -g 121 runner
# sudo usermod -aG sudo runner
# sudo usermod -aG docker runner

# Configure the GitHub Actions runner
if [ ! -f .runner ]; then
./config.sh --url "${GITHUB_URL}" --token "${RUNNER_TOKEN}" --name "${RUNNER_NAME}" --unattended --replace
Expand All @@ -22,5 +17,14 @@ RUNNER_NAME=${RUNNER_NAME:-"default-runner"}
# Trap SIGTERM and SIGINT to allow for cleanup
trap './config.sh remove --unattended && exit 0' SIGTERM SIGINT

# Start the Docker daemon
/usr/local/bin/dockerd-entrypoint.sh &

# Wait for Docker daemon to start
while ! docker info > /dev/null 2>&1; do
echo "Waiting for Docker daemon to start..."
sleep 1
done

# Start the runner
./run.sh

0 comments on commit 4f2d513

Please sign in to comment.