From 36c120d1bfd08f0086bf23d470cedbd2dc331091 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 16 Aug 2026 16:26:36 -0100 Subject: [PATCH] Gitea runner action --- .dockerignore | 11 +++- .gitea/workflows/build-docker.yml | 55 +++++++++++++++++++ Dockerfile | 88 ++++++++++++++++++++----------- 3 files changed, 121 insertions(+), 33 deletions(-) create mode 100644 .gitea/workflows/build-docker.yml diff --git a/.dockerignore b/.dockerignore index 6edb5b2f..0f0c37ae 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,9 @@ -public/img -storage +.git +vendor +node_modules +storage/logs +storage/framework/cache/* +storage/framework/sessions/* +storage/framework/views/* +storage/app/public +.env diff --git a/.gitea/workflows/build-docker.yml b/.gitea/workflows/build-docker.yml new file mode 100644 index 00000000..eb4f70c1 --- /dev/null +++ b/.gitea/workflows/build-docker.yml @@ -0,0 +1,55 @@ +name: Build and Deploy +run-name: ${{ gitea.actor }} is building ${{ gitea.repository }} + +on: + push: + branches: + - main + paths: + - 'Dockerfile' + - 'composer.json' + - 'composer.lock' + - '.gitea/workflows/build-docker.yml' + +jobs: + build: + runs-on: ubuntu-latest + + env: + REGISTRY: git.nhgooi.nl + IMAGE: git.nhgooi.nl/nh_gooi/nhgooi.nl + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Login to Gitea Container Registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | \ + docker login "$REGISTRY" \ + -u "${{ gitea.actor }}" \ + --password-stdin + + - name: Build image + run: | + docker build \ + -t "$IMAGE:${{ gitea.sha }}" \ + -t "$IMAGE:latest" \ + . + + - name: Push image + run: | + docker push "$IMAGE:${{ gitea.sha }}" + docker push "$IMAGE:latest" + + - name: Trigger deployment + run: | + curl --fail-with-body \ + -X POST \ + -H "Content-Type: application/json" \ + -d '{ + "image": "'"$IMAGE:${{ gitea.sha }}"'", + "commit": "${{ gitea.sha }}", + "repository": "${{ gitea.repository }}" + }' \ + "${{ secrets.DEPLOY_WEBHOOK_URL }}" diff --git a/Dockerfile b/Dockerfile index daab0601..5d3bdb06 100755 --- a/Dockerfile +++ b/Dockerfile @@ -1,38 +1,64 @@ -FROM php:8.2-apache +FROM php:8.3-apache -RUN apt-get update \ - && apt-get -y install \ - g++ \ - libcurl4-gnutls-dev \ - libxml2-dev \ - libxslt-dev \ - libzip-dev \ - zlib1g-dev \ - msmtp \ - unzip \ - git \ - locales \ - --no-install-recommends \ - && docker-php-ext-install pdo pdo_mysql mysqli xsl xml zip opcache \ - && a2enmod rewrite proxy proxy_http headers \ - && apt-get purge -y g++ \ - && apt-get autoremove -y \ - && rm -r /var/lib/apt/lists/* +RUN apt-get update && apt-get install -y \ + git \ + curl \ + libicu-dev \ + libzip-dev \ + libonig-dev \ + libssh2-1 \ + libssh2-1-dev \ + && rm -rf /var/lib/apt/lists/* -# Get latest Composer -COPY --from=composer:latest /usr/bin/composer /usr/bin/composer +RUN pecl install ssh2 \ + && docker-php-ext-enable ssh2 \ + && docker-php-ext-configure intl \ + && docker-php-ext-install \ + pdo \ + pdo_mysql \ + mysqli \ + intl \ + ftp \ + mbstring \ + bcmath \ + zip -# Update the default apache site with the config we created. -ADD docker/apache.conf /etc/apache2/sites-enabled/000-default.conf +RUN a2enmod rewrite -WORKDIR /var/www/html -COPY . /var/www/html +COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer WORKDIR /var/www/app -RUN mkdir -p storage/framework/{sessions,views,cache,cache/data} && \ - chown -R www-data:www-data storage/framework && \ - chmod -R 775 storage -#RUN php artisan cache:clear && \ -# php artisan config:clear && \ -# php artisan view:clear +ENV APACHE_DOCUMENT_ROOT=/var/www/app/public + +RUN sed -ri \ + -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' \ + /etc/apache2/sites-available/*.conf \ + /etc/apache2/apache2.conf \ + /etc/apache2/conf-available/*.conf + +RUN echo '\n\ + AllowOverride All\n\ + Require all granted\n\ +' > /etc/apache2/conf-available/laravel.conf \ + && a2enconf laravel + +COPY composer.json composer.lock ./ + +# Note: for Laravel, the COPY . . needs to be before the composer install +COPY . . + +RUN composer install \ + --no-dev \ + --prefer-dist \ + --no-interaction \ + --optimize-autoloader + +RUN mkdir -p \ + storage/framework/cache/data \ + storage/framework/sessions \ + storage/framework/views \ + && chown -R www-data:www-data storage bootstrap/cache \ + && chmod -R ug+rwx storage bootstrap/cache + +EXPOSE 80