diff --git a/.github/workflows/00-self-hosted-runner.yaml b/.github/workflows/00-self-hosted-runner.yaml new file mode 100644 index 0000000..b1ad68f --- /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-hosted-runner +on: + push: + branches: + - hosted-runner + +env: + DATA: '/dev/null' + +jobs: + CI-runner-on-my-laptop: + runs-on: self-hosted + + 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