From cb5ef1f0b359b2f9f47f81fe87c7285454f88783 Mon Sep 17 00:00:00 2001 From: Kevin Alberts Date: Sat, 9 Nov 2024 13:19:51 +0100 Subject: [PATCH] Add dockerfile and workflow --- .github/workflows/build_docker_image.yml | 63 ++++++++++++++++++++++++ Dockerfile | 25 ++++++++++ _config.yml | 3 +- 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build_docker_image.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build_docker_image.yml b/.github/workflows/build_docker_image.yml new file mode 100644 index 0000000..4682e2a --- /dev/null +++ b/.github/workflows/build_docker_image.yml @@ -0,0 +1,63 @@ +name: Build docker image and run tests + +on: [push, pull_request] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + + - name: Cleanup untagged images older than 1 week + uses: snok/container-retention-policy@v2 + with: + image-names: Amelie-GDPR-document + cut-off: 1 week ago UTC + account-type: org + org-name: Inter-Actief + token: ${{ secrets.GITHUB_TOKEN }} + token-type: github-token + untagged-only: true + + - name: Cleanup tagged images (except main) older than 1 month + uses: snok/container-retention-policy@v2 + with: + image-names: Amelie-GDPR-document + cut-off: 1 month ago UTC + account-type: org + org-name: Inter-Actief + token: ${{ secrets.GITHUB_TOKEN }} + token-type: github-token + skip-tags: main + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..dd8daee --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +# Build the static site with Jekyll +FROM jekyll/jekyll:stable as builder + +# Copy sources +COPY . /srv/jekyll + +# Set workdir +WORKDIR /srv/jekyll + +# Install gems and build site +#RUN bundle install && \ +RUN JEKYLL_ENV=production jekyll build + +# Build nginx container +FROM nginx:latest + +# Copy build artifacts +COPY --from=builder /srv/jekyll/_site /usr/share/nginx/html + +# Expose the web port +EXPOSE 80 + +# Start nginx +CMD ["nginx", "-g", "daemon off;"] + diff --git a/_config.yml b/_config.yml index 0471756..2b127b6 100644 --- a/_config.yml +++ b/_config.yml @@ -4,8 +4,9 @@ email: privacy@inter-actief.net description: > # this means to ignore newlines until "baseurl:" In dit document kan je alle details over privacy binnen Inter-*Actief* vinden. baseurl: "" # the subpath of your site, e.g. /blog/ -url: "" # the base hostname & protocol for your site +url: "https://privacy.ia.utwente.nl" # the base hostname & protocol for your site github_username: Inter-Actief +repository: Inter-Actief/Amelie-GDPR-document # Build settings markdown: kramdown