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..186ce2f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,84 +1,83 @@ # 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 - -FROM mcr.microsoft.com/dotnet/runtime-deps:6.0-jammy - -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 \ - curl \ - unzip \ - 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/* +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 \ + 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 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 -WORKDIR /home/runner +# 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 && \ + service mariadb start && \ + 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 -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 +# 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 + +# Install Chrome +RUN apt-get update -qq && \ + 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 + +# 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 install -o root -g root -m 755 docker/* /usr/bin/ && rm -rf docker +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 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