From 5130e2980429f3f2186c7f3e017bc7439895f8f3 Mon Sep 17 00:00:00 2001 From: Simone Date: Sun, 27 Oct 2024 00:23:58 +0200 Subject: [PATCH 1/4] test --- .gitignore | 1 + Dockerfile | 119 +++++++++++++++++++++++++++++------------------------ 2 files changed, 66 insertions(+), 54 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 1cae0db..4c10de5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,71 +1,64 @@ # Source: https://github.com/dotnet/dotnet-docker -FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy as build +FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy AS build -ARG RUNNER_ARCH="x64" # Replace value with the latest runner release version # source: https://github.com/actions/runner/releases # ex: 2.303.0 -ARG RUNNER_VERSION="2.311.0" +ARG RUNNER_VERSION="2.320.0" +ARG RUNNER_ARCH="x64" # Replace value with the latest runner-container-hooks release version # source: https://github.com/actions/runner-container-hooks/releases # ex: 0.3.1 -ARG RUNNER_CONTAINER_HOOKS_VERSION=0.5.0 -ARG DOCKER_VERSION=24.0.6 -ARG BUILDX_VERSION=0.11.2 - -# Install necessary tools -RUN apt update -y && apt install curl unzip lsb-release gpg -y - -WORKDIR /actions-runner -RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ - && tar xzf ./runner.tar.gz \ - && rm runner.tar.gz - -RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \ - && unzip ./runner-container-hooks.zip -d ./k8s \ - && rm runner-container-hooks.zip - -RUN curl -fLo docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-${DOCKER_VERSION}.tgz \ - && tar zxvf docker.tgz \ - && rm -rf docker.tgz \ - && mkdir -p /usr/local/lib/docker/cli-plugins \ - && curl -fLo /usr/local/lib/docker/cli-plugins/docker-buildx \ - "https://github.com/docker/buildx/releases/download/v${BUILDX_VERSION}/buildx-v${BUILDX_VERSION}.linux-amd64" \ - && chmod +x /usr/local/lib/docker/cli-plugins/docker-buildx +ARG RUNNER_CONTAINER_HOOKS_VERSION="0.6.1" -FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy +ARG NODE_VERSION=20 ENV DEBIAN_FRONTEND=noninteractive ENV RUNNER_MANUALLY_TRAP_SIG=1 ENV ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1 -ENV ImageOS=ubuntu22 -RUN apt-get update -y \ - && apt-get install -y --no-install-recommends \ - sudo \ - lsb-release \ - git \ +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +RUN apt-get update -qq \ + && apt-get upgrade -qq -y \ + && apt-get install -q -y --no-install-recommends \ curl \ unzip \ + sudo\ + jq \ + git \ gpg \ - && rm -rf /var/lib/apt/lists/* - -# Install MariaDB -RUN apt-get update -y \ - && apt-get install -y --no-install-recommends \ - mariadb-server \ - && rm -rf /var/lib/apt/lists/* - -# Configure MariaDB -RUN echo 'sort_buffer_size = 256000000' >> /etc/mysql/mariadb.conf.d/50-server.cnf - -# Install Redis -RUN curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg \ - && echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list \ - && apt-get update -y \ - && apt-get install -y --no-install-recommends \ - redis \ - && rm -rf /var/lib/apt/lists/* + openssl \ + gpg-agent \ + software-properties-common \ + && curl -sL https://deb.nodesource.com/setup_20.x | bash - \ + && apt-get install -q -y \ + nodejs \ + && apt-get update -qq \ + && apt-add-repository ppa:ondrej/php -y \ + && apt-get update -qq \ + && apt-get install -q -y --no-install-recommends \ + php8.3 \ + php8.3-ctype \ + php8.3-curl \ + php8.3-fileinfo \ + php8.3-fpm \ + php8.3-iconv \ + php8.3-mbstring \ + php8.3-phar \ + php8.3-simplexml \ + php8.3-xml \ + php8.3-xmlwriter \ + php8.3-zip \ + php8.3-gd \ + php8.3-intl \ + php8.3-tokenizer \ + php8.3-xmlreader \ + php8.3-posix \ + php8.3-redis \ + php8.3-mysql + +COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer RUN adduser --disabled-password --gecos "" --uid 1001 runner \ && groupadd docker --gid 123 \ @@ -74,11 +67,29 @@ RUN adduser --disabled-password --gecos "" --uid 1001 runner \ && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers +# Imposta la password di root per MariaDB +ARG MYSQL_ROOT_PASSWORD=root + +# Installazione di MariaDB con configurazione della password +RUN apt-get update -qq && \ + echo "mariadb-server mariadb-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections && \ + echo "mariadb-server mariadb-server/root_password_again password $MYSQL_ROOT_PASSWORD" | debconf-set-selections && \ + apt-get install -y mariadb-server && \ + service mariadb start && \ + # Disabilita l'uso di unix_socket per l'utente root e abilita l'autenticazione con password + mariadb -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'; FLUSH PRIVILEGES;" + +# Configure MariaDB +RUN echo 'sort_buffer_size = 256000000' >> /etc/mysql/mariadb.conf.d/50-server.cnf + WORKDIR /home/runner -COPY --chown=runner:docker --from=build /actions-runner . -COPY --from=build /usr/local/lib/docker/cli-plugins/docker-buildx /usr/local/lib/docker/cli-plugins/docker-buildx +RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ + && tar xzf ./runner.tar.gz \ + && rm runner.tar.gz -RUN install -o root -g root -m 755 docker/* /usr/bin/ && rm -rf docker +RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \ + && unzip ./runner-container-hooks.zip -d ./k8s \ + && rm runner-container-hooks.zip USER runner From 62a4fcf11786b8dd06ce68446b4bb11f0535e632 Mon Sep 17 00:00:00 2001 From: Simone Date: Sun, 27 Oct 2024 01:13:53 +0200 Subject: [PATCH 2/4] add redis --- Dockerfile | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 4c10de5..00bffc6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -82,6 +82,14 @@ RUN apt-get update -qq && \ # Configure MariaDB RUN echo 'sort_buffer_size = 256000000' >> /etc/mysql/mariadb.conf.d/50-server.cnf +# Installa Redis +RUN apt-get update -qq && \ + apt-get install -y redis-server && \ + # Configura Redis per eseguire tutte le interfacce di rete (opzionale, solo per test) + sed -i 's/^# bind 127.0.0.1 ::1/bind 0.0.0.0/' /etc/redis/redis.conf && \ + # Imposta Redis in modalità background + echo "daemonize yes" >> /etc/redis/redis.conf + WORKDIR /home/runner RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ From 9b5aca7423266ddb5fd4fa6655f93c8d8d46b205 Mon Sep 17 00:00:00 2001 From: Simone Date: Sun, 27 Oct 2024 15:10:13 +0100 Subject: [PATCH 3/4] add chrome (#5) * test chrome * add chrome * Update Dockerfile * Update Dockerfile --- Dockerfile | 103 ++++++++++++++++++----------------------------------- 1 file changed, 35 insertions(+), 68 deletions(-) diff --git a/Dockerfile b/Dockerfile index 00bffc6..afb3a95 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,94 +10,61 @@ ARG RUNNER_ARCH="x64" # source: https://github.com/actions/runner-container-hooks/releases # ex: 0.3.1 ARG RUNNER_CONTAINER_HOOKS_VERSION="0.6.1" - ARG NODE_VERSION=20 +ARG MYSQL_ROOT_PASSWORD=root +ARG CHROME_VERSION="130.0.6723.69" -ENV DEBIAN_FRONTEND=noninteractive -ENV RUNNER_MANUALLY_TRAP_SIG=1 -ENV ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1 +ENV DEBIAN_FRONTEND=noninteractive \ + RUNNER_MANUALLY_TRAP_SIG=1 \ + ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT=1 \ + CHROME_BIN="/usr/bin/google-chrome" SHELL ["/bin/bash", "-o", "pipefail", "-c"] -RUN apt-get update -qq \ - && apt-get upgrade -qq -y \ - && apt-get install -q -y --no-install-recommends \ - curl \ - unzip \ - sudo\ - jq \ - git \ - gpg \ - openssl \ - gpg-agent \ - software-properties-common \ - && curl -sL https://deb.nodesource.com/setup_20.x | bash - \ - && apt-get install -q -y \ - nodejs \ - && apt-get update -qq \ - && apt-add-repository ppa:ondrej/php -y \ - && apt-get update -qq \ - && apt-get install -q -y --no-install-recommends \ - php8.3 \ - php8.3-ctype \ - php8.3-curl \ - php8.3-fileinfo \ - php8.3-fpm \ - php8.3-iconv \ - php8.3-mbstring \ - php8.3-phar \ - php8.3-simplexml \ - php8.3-xml \ - php8.3-xmlwriter \ - php8.3-zip \ - php8.3-gd \ - php8.3-intl \ - php8.3-tokenizer \ - php8.3-xmlreader \ - php8.3-posix \ - php8.3-redis \ - php8.3-mysql +RUN apt-get update -qq && \ + apt-get upgrade -qq -y && \ + apt-get install -q -y --no-install-recommends \ + curl wget unzip sudo jq gnupg git gpg openssl gpg-agent software-properties-common \ + && curl -sL https://deb.nodesource.com/setup_${NODE_VERSION}.x | bash - && \ + apt-add-repository ppa:ondrej/php -y && \ + apt-get update -qq && \ + apt-get install -q -y --no-install-recommends \ + nodejs php8.3 php8.3-{ctype,curl,fileinfo,fpm,iconv,mbstring,phar,simplexml,xml,xmlwriter,zip,gd,intl,tokenizer,xmlreader,posix,redis,mysql,pcov} \ + && apt-get install -q -y mariadb-server redis-server \ + && apt-get clean && rm -rf /var/lib/apt/lists/* COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer RUN adduser --disabled-password --gecos "" --uid 1001 runner \ && groupadd docker --gid 123 \ - && usermod -aG sudo runner \ - && usermod -aG docker runner \ + && usermod -aG sudo,docker runner \ && echo "%sudo ALL=(ALL:ALL) NOPASSWD:ALL" > /etc/sudoers \ && echo "Defaults env_keep += \"DEBIAN_FRONTEND\"" >> /etc/sudoers -# Imposta la password di root per MariaDB -ARG MYSQL_ROOT_PASSWORD=root - -# Installazione di MariaDB con configurazione della password -RUN apt-get update -qq && \ - echo "mariadb-server mariadb-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections && \ +# Configure MariaDB +RUN echo "mariadb-server mariadb-server/root_password password $MYSQL_ROOT_PASSWORD" | debconf-set-selections && \ echo "mariadb-server mariadb-server/root_password_again password $MYSQL_ROOT_PASSWORD" | debconf-set-selections && \ - apt-get install -y mariadb-server && \ service mariadb start && \ - # Disabilita l'uso di unix_socket per l'utente root e abilita l'autenticazione con password - mariadb -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'; FLUSH PRIVILEGES;" + mariadb -u root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${MYSQL_ROOT_PASSWORD}'; FLUSH PRIVILEGES;" && \ + echo 'sort_buffer_size = 256000000' >> /etc/mysql/mariadb.conf.d/50-server.cnf -# Configure MariaDB -RUN echo 'sort_buffer_size = 256000000' >> /etc/mysql/mariadb.conf.d/50-server.cnf +# Configure Redis to listen on all interfaces +RUN sed -i 's/^# bind 127.0.0.1 ::1/bind 0.0.0.0/' /etc/redis/redis.conf -# Installa Redis +# Install Chrome RUN apt-get update -qq && \ - apt-get install -y redis-server && \ - # Configura Redis per eseguire tutte le interfacce di rete (opzionale, solo per test) - sed -i 's/^# bind 127.0.0.1 ::1/bind 0.0.0.0/' /etc/redis/redis.conf && \ - # Imposta Redis in modalità background - echo "daemonize yes" >> /etc/redis/redis.conf + apt-get install -y fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libatspi2.0-0 \ + libcairo2 libcups2 libdrm2 libgbm1 libgtk-3-0 libnspr4 libnss3 \ + libpango-1.0-0 libvulkan1 libxcomposite1 libxdamage1 libxext6 \ + libxfixes3 libxkbcommon0 libxrandr2 xdg-utils && \ + wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb && \ + apt install -y /tmp/chrome.deb && rm /tmp/chrome.deb WORKDIR /home/runner -RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz \ - && tar xzf ./runner.tar.gz \ - && rm runner.tar.gz - -RUN curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip \ - && unzip ./runner-container-hooks.zip -d ./k8s \ - && rm runner-container-hooks.zip +RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz && \ + tar xzf ./runner.tar.gz && rm runner.tar.gz && \ + curl -f -L -o runner-container-hooks.zip https://github.com/actions/runner-container-hooks/releases/download/v${RUNNER_CONTAINER_HOOKS_VERSION}/actions-runner-hooks-k8s-${RUNNER_CONTAINER_HOOKS_VERSION}.zip && \ + unzip ./runner-container-hooks.zip -d ./k8s && rm runner-container-hooks.zip USER runner From 72dd362325d0605a68de3ad8912a569825c1366c Mon Sep 17 00:00:00 2001 From: Simone Date: Tue, 29 Oct 2024 12:46:50 +0100 Subject: [PATCH 4/4] Add minio --- Dockerfile | 13 +++++++++++ etc/init.d/minio | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 etc/init.d/minio diff --git a/Dockerfile b/Dockerfile index afb3a95..186ce2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -60,6 +60,19 @@ RUN apt-get update -qq && \ wget --no-verbose -O /tmp/chrome.deb https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}-1_amd64.deb && \ apt install -y /tmp/chrome.deb && rm /tmp/chrome.deb +# Installazione di MinIO +RUN wget https://dl.min.io/server/minio/release/linux-amd64/archive/minio_20241013133411.0.0_amd64.deb -O minio.deb && \ + dpkg -i minio.deb + +# Installazione di MinIO Client +RUN wget https://dl.min.io/client/mc/release/linux-amd64/mc -O mc && \ + chmod +x mc && mv mc /usr/local/bin/mc + +COPY /etc /etc + +RUN chmod +x /etc/init.d/minio && \ + update-rc.d minio defaults + WORKDIR /home/runner RUN curl -f -L -o runner.tar.gz https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/actions-runner-linux-${RUNNER_ARCH}-${RUNNER_VERSION}.tar.gz && \ diff --git a/etc/init.d/minio b/etc/init.d/minio new file mode 100644 index 0000000..f4e063d --- /dev/null +++ b/etc/init.d/minio @@ -0,0 +1,57 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: minio +# Required-Start: $network $remote_fs $syslog +# Required-Stop: $network $remote_fs $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start MinIO Server +# Description: Controls MinIO as a service +### END INIT INFO + +MINIO_BIN="/usr/local/bin/minio" +MINIO_OPTS="--console-address :9001 /home/runner/minio" +MINIO_USER="runner" +MINIO_LOG="/var/log/minio.log" + +start() { + echo "Starting MinIO..." + start-stop-daemon --start --background --make-pidfile --pidfile /var/run/minio.pid \ + --chuid $MINIO_USER --exec $MINIO_BIN -- server $MINIO_OPTS >> $MINIO_LOG 2>&1 + echo "MinIO started." +} + +stop() { + echo "Stopping MinIO..." + start-stop-daemon --stop --pidfile /var/run/minio.pid + echo "MinIO stopped." +} + +status() { + if [ -f /var/run/minio.pid ]; then + echo "MinIO is running with PID $(cat /var/run/minio.pid)." + else + echo "MinIO is not running." + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop + start + ;; + status) + status + ;; + *) + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac +exit 0