From 82772e507095080ae47ce5a1dac2ff2e756d2d88 Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:43:40 -0700 Subject: [PATCH 1/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 31 ++++++++++++++++++++ .gitignore | 1 + c2w/Dockerfile | 13 -------- c2w/GitHostedRunner/Dockerfile | 29 ++++++++++++++++++ c2w/GitHostedRunner/README.md | 20 +++++++++++++ c2w/GitHostedRunner/docker-compose.yaml | 9 ++++++ c2w/work4all/Dockerfile | 27 +++++++++++++++++ c2w/{ => work4all}/README.md | 2 +- 8 files changed, 118 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/00-self-hosted-runner.yaml delete mode 100644 c2w/Dockerfile create mode 100644 c2w/GitHostedRunner/Dockerfile create mode 100644 c2w/GitHostedRunner/README.md create mode 100644 c2w/GitHostedRunner/docker-compose.yaml create mode 100644 c2w/work4all/Dockerfile rename c2w/{ => work4all}/README.md (92%) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml new file mode 100644 index 0000000..fa1c854 --- /dev/null +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -0,0 +1,31 @@ +################################## +# +# IMPORTANT: +# THIS WORKFLOW REQUIRE YOU RUN +# A RUNNER CONTAINER IN YOUR LAPTOP +# FOR MORE INFORMATION SEE: +# +# ..c2w/GitHostedRunner/README.md +# +################################## +--- +name: CI-test-actions +on: + push: + branches: + - hosted-runner + +env: + DATA: '/dev/null' + +jobs: + CI-test-actions: + runs-on: eda-hosted-runner + + steps: + + - name: Show versions + run: | + echo "hello world" + echo "bye bye world" + echo ${{ env.DATA }} > /tmp/test.txt \ No newline at end of file diff --git a/.gitignore b/.gitignore index b2841f1..2bb925f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ **/demo-inventory.ini temp/ tmp/ +security.md diff --git a/c2w/Dockerfile b/c2w/Dockerfile deleted file mode 100644 index 0ffb0a0..0000000 --- a/c2w/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM ubuntu:22.04 - -RUN apt-get update && \ -apt-get update && apt-get install -y curl wget ansible unzip bash git openssh-client jq && \ -wget -q https://releases.hashicorp.com/terraform/1.9.5/terraform_1.9.5_linux_386.zip && \ -unzip terraform_1.9.5_linux_386.zip && \ -mv terraform /usr/local/bin/terraform && \ -chmod +x /usr/local/bin/terraform && \ -rm LICENSE.txt terraform_1.9.5_linux_386.zip - -ENTRYPOINT ["/bin/bash"] - - diff --git a/c2w/GitHostedRunner/Dockerfile b/c2w/GitHostedRunner/Dockerfile new file mode 100644 index 0000000..beb7182 --- /dev/null +++ b/c2w/GitHostedRunner/Dockerfile @@ -0,0 +1,29 @@ +FROM ubuntu:22.04 + +WORKDIR /actions-runner + + +ENV RUNNER_NAME="eda-hosted-runner" +ENV RUNNER_WORK_DIRECTORY="_work" +ENV GITHUB_REPOSITORY_URL="https://github.com/jpradoar/event-driven-architecture" +ENV RUNNER_TOKEN="" + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ +apt-get install -y curl jq sudo tar git && \ +rm -rf /var/lib/apt/lists/* && \ +curl -o actions-runner-linux-x64-2.320.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.320.0/actions-runner-linux-x64-2.320.0.tar.gz && \ +tar xzf ./actions-runner-linux-x64-2.320.0.tar.gz && \ +rm -rf actions-runner-linux-x64-2.320.0.tar.gz && \ +apt-get clean && \ +useradd -m github-runner && \ +mkdir -p /actions-runner && \ +chown -R github-runner:github-runner /actions-runner && \ +echo "github-runner ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + +USER github-runner + +RUN sudo ./bin/installdependencies.sh && chmod +x ./config.sh ./run.sh + +CMD ./config.sh --url $GITHUB_REPOSITORY_URL --token $RUNNER_TOKEN --name $RUNNER_NAME --work $RUNNER_WORK_DIRECTORY --unattended --replace && ./run.sh \ No newline at end of file diff --git a/c2w/GitHostedRunner/README.md b/c2w/GitHostedRunner/README.md new file mode 100644 index 0000000..175d4d4 --- /dev/null +++ b/c2w/GitHostedRunner/README.md @@ -0,0 +1,20 @@ +# Github self-hosted runner in docker container + + +### Build + docker build -t eda-hosted-runner . + + +### Run hosted runner + docker run \ + --rm \ + -itd \ + --name eda-hosted-runner \ + --hostname eda-hosted-runner \ + -e RUNNER_TOKEN=YOUR_GITHUB_RUNNER_TOKEN_HERE \ + -e GITHUB_REPOSITORY_URL=https://github.com/jpradoar/event-driven-architecture \ + eda-hosted-runner:latest + + +### Using docker-compsoe + docker-compose up -d \ No newline at end of file diff --git a/c2w/GitHostedRunner/docker-compose.yaml b/c2w/GitHostedRunner/docker-compose.yaml new file mode 100644 index 0000000..892606a --- /dev/null +++ b/c2w/GitHostedRunner/docker-compose.yaml @@ -0,0 +1,9 @@ +version: '3.8' +services: + github-runner: + image: eda-hosted-runner:latest + environment: + - RUNNER_TOKEN=YOUR_GITHUB_RUNNER_TOKEN_HERE + - GITHUB_REPOSITORY_URL=https://github.com/jpradoar/event-driven-architecture + stdin_open: true + tty: true \ No newline at end of file diff --git a/c2w/work4all/Dockerfile b/c2w/work4all/Dockerfile new file mode 100644 index 0000000..3deeda9 --- /dev/null +++ b/c2w/work4all/Dockerfile @@ -0,0 +1,27 @@ +FROM ubuntu:22.04 + +ARG DEBIAN_FRONTEND=noninteractive + +RUN apt-get update && \ +apt-get install -y \ +curl \ +wget \ +vim \ +netcat-traditional \ +ansible \ +unzip \ +bash \ +git \ +openssh-client \ +jq && \ +wget -q https://releases.hashicorp.com/terraform/1.9.5/terraform_1.9.5_linux_386.zip && \ +unzip -qq terraform_1.9.5_linux_386.zip && \ +mv terraform /usr/local/bin/terraform && \ +chmod +x /usr/local/bin/terraform && \ +rm LICENSE.txt terraform_1.9.5_linux_386.zip && \ +apt-get clean && \ +rm -rf /var/lib/apt/lists/* + +ENTRYPOINT ["/bin/bash"] + + diff --git a/c2w/README.md b/c2w/work4all/README.md similarity index 92% rename from c2w/README.md rename to c2w/work4all/README.md index 26f49d4..df34e02 100644 --- a/c2w/README.md +++ b/c2w/work4all/README.md @@ -2,7 +2,7 @@ ### Build docker container - docker build -t demo . + docker build -t c2w . ### Create folder to share between container and your local From 8d931884bcea39eaaecb30e68cb1bad4f9720353 Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:46:15 -0700 Subject: [PATCH 2/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml index fa1c854..fe16e08 100644 --- a/.github/workflows/00-self-hosted-runner.yaml +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -20,7 +20,7 @@ env: jobs: CI-test-actions: - runs-on: eda-hosted-runner + runs-on: self-hosted steps: From aab440bbe7f85eb13306cfcea5d10faa6fc9e9ed Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:47:19 -0700 Subject: [PATCH 3/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml index fe16e08..469cfae 100644 --- a/.github/workflows/00-self-hosted-runner.yaml +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -9,7 +9,7 @@ # ################################## --- -name: CI-test-actions +name: CI-hosted-runner on: push: branches: From b53998907154330f7d501fd7228d2b1d92d57287 Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:48:30 -0700 Subject: [PATCH 4/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml index 469cfae..26ab17c 100644 --- a/.github/workflows/00-self-hosted-runner.yaml +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -19,7 +19,7 @@ env: DATA: '/dev/null' jobs: - CI-test-actions: + CI-hosted-runner: runs-on: self-hosted steps: From 54b845e83ac97a7f72d7909a920e4f8edaf51242 Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:49:43 -0700 Subject: [PATCH 5/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml index 26ab17c..efb44e1 100644 --- a/.github/workflows/00-self-hosted-runner.yaml +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -19,7 +19,7 @@ env: DATA: '/dev/null' jobs: - CI-hosted-runner: + CI-hosted-runner-docker-on-my-laptop: runs-on: self-hosted steps: From 6b96df705a1f772780a44bbc52a9e5efd5cda1bd Mon Sep 17 00:00:00 2001 From: Jonathan Prado Date: Wed, 13 Nov 2024 11:50:35 -0700 Subject: [PATCH 6/6] [feat]: Add docker container to work anywhere --- .github/workflows/00-self-hosted-runner.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml index efb44e1..b1ad68f 100644 --- a/.github/workflows/00-self-hosted-runner.yaml +++ b/.github/workflows/00-self-hosted-runner.yaml @@ -19,7 +19,7 @@ env: DATA: '/dev/null' jobs: - CI-hosted-runner-docker-on-my-laptop: + CI-runner-on-my-laptop: runs-on: self-hosted steps: