From 935c59dd8bac7cd11e181306b202f9ed75ef0971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Z=C3=A1le=C5=A1=C3=A1k?= Date: Fri, 8 May 2026 22:00:28 +0000 Subject: [PATCH] CI: speed up build --- .gitea/workflows/pages-deploy.yml | 26 +++----------------------- Dockerfile | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 23 deletions(-) create mode 100644 Dockerfile diff --git a/.gitea/workflows/pages-deploy.yml b/.gitea/workflows/pages-deploy.yml index 9cfe5c9..f8534d1 100644 --- a/.gitea/workflows/pages-deploy.yml +++ b/.gitea/workflows/pages-deploy.yml @@ -35,29 +35,11 @@ jobs: # If using the 'assets' git submodule from Chirpy Starter, uncomment above # (See: https://github.com/cotes2020/chirpy-starter/tree/main/assets) - - name: Setup Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: 3.3 - bundler-cache: true - - - name: Build site - run: bundle exec jekyll b -d "_site${{ steps.pages.outputs.base_path }}" - env: - JEKYLL_ENV: "production" - - - name: Test site - run: | - bundle exec htmlproofer _site \ - \-\-disable-external \ - \-\-ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" - - name: Build Docker image run: | - echo "FROM nginx:alpine" > Dockerfile - echo "COPY _site /usr/share/nginx/html" >> Dockerfile - echo "EXPOSE 80" >> Dockerfile - docker build -t ${CI_REGISTRY_IMAGE:-git.pixx.cz/${{ gitea.repository }}}:${{ gitea.sha }} . + docker build \ + -t git.pixx.cz/${{ gitea.repository }}:${{ gitea.sha }} \ + -t git.pixx.cz/${{ gitea.repository }}:latest . - name: Login to Gitea Container Registry run: | @@ -66,8 +48,6 @@ jobs: - name: Push Docker image run: | - docker tag ${CI_REGISTRY_IMAGE:-git.pixx.cz/${{ gitea.repository }}}:${{ gitea.sha }} \ - ${CI_REGISTRY_IMAGE:-git.pixx.cz/${{ gitea.repository }}}:latest docker push ${CI_REGISTRY_IMAGE:-git.pixx.cz/${{ gitea.repository }}}:${{ gitea.sha }} docker push ${CI_REGISTRY_IMAGE:-git.pixx.cz/${{ gitea.repository }}}:latest diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8f03516 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +# --- Stage 1: Build & Test --- +FROM ruby:3.3 AS builder + +# Instalace závislostí pro html-proofer (pokud jsou potřeba) +RUN apt-get update && apt-get install -y build-essential + +WORKDIR /srv/jekyll +COPY Gemfile* ./ +RUN bundle install + +COPY . . + +# Samotný build webu +RUN JEKYLL_ENV=production bundle exec jekyll build + +# TEST: Pokud htmlproofer skončí chybou, celý Docker build selže +RUN bundle exec htmlproofer ./_site \ + --disable-external \ + --ignore-urls "/^http:\/\/127.0.0.1/,/^http:\/\/0.0.0.0/,/^http:\/\/localhost/" + +# --- Stage 2: Final Image --- +FROM nginx:alpine +COPY --from=builder /srv/jekyll/_site /usr/share/nginx/html +EXPOSE 80