From 271eb5e9e36547ba47945ab653a219722c53ae1f Mon Sep 17 00:00:00 2001 From: Lennart Krauch Date: Thu, 21 Dec 2023 10:34:31 +0100 Subject: [PATCH 1/4] added docker build --- .dockerignore | 1 + .github/workflows/CI.yaml | 48 ++++++++++++++++++++++++++++ Dockerfile | 17 ++++++++++ nginx/nginx.conf | 31 ++++++++++++++++++ src/pages/[lang]/Legal/Cookies.astro | 2 +- src/pages/[lang]/Legal/Privacy.astro | 2 +- src/pages/[lang]/Legal/Terms.astro | 2 +- 7 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 nginx/nginx.conf diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 70fcbe3..4e7b11c 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -23,3 +23,51 @@ jobs: - name: Code Linting run: npm run lint + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login Github Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: scrumlr.io - Landing Page - Build + id: meta-landing-page + uses: docker/metadata-action@v4 + with: + images: | + ghcr.io/inovex/scrumlr.io-landing-page/image + tags: | + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=raw,value=latest + type=sha,prefix=sha-,format=short + labels: | + org.opencontainers.image.authors=info@scrumlr.io + org.opencontainers.image.url=https://github.com/inovex/scrumlr.io/pkgs/container/scrumlr.io-landing-page%2Fimage + org.opencontainers.image.source=https://github.com/inovex/scrumlr.io-landing-page + org.opencontainers.image.vendor=inovex + org.opencontainers.image.licenses=MIT + org.opencontainers.image.title=scrumlr.io - Landing Page + org.opencontainers.image.description=The landing page of scrumlr.io + + - name: Set up Docker buildx + uses: docker/setup-buildx-action@v2 + + - name: Push landing page image + id: push-landing-page + uses: docker/build-push-action@v4 + with: + push: true + tags: ${{ steps.meta-landing-page.outputs.tags }} + labels: ${{ steps.meta-landing-page.outputs.labels }} + build-args: | + DIRECTUS_URL = ${{ secrets.DIRECTUS_URL }} + DIRECTUS_TOKEN = ${{ secrets.DIRECTUS_TOKEN }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..92e053f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM node:18 AS build +WORKDIR /app +ARG DIRECTUS_URL +ARG DIRECTUS_TOKEN +COPY package*.json ./ +RUN npm install -g pnpm +RUN pnpm install +COPY . . +RUN echo "DIRECTUS_URL = ${DIRECTUS_URL}" >> .env +RUN echo "DIRECTUS_TOKEN = ${DIRECTUS_TOKEN}" >> .env +RUN pnpm run build +RUN rm -rf .env + +FROM nginx:alpine AS runtime +COPY ./nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=build /app/dist /usr/share/nginx/html +EXPOSE 8080 \ No newline at end of file diff --git a/nginx/nginx.conf b/nginx/nginx.conf new file mode 100644 index 0000000..a1a6187 --- /dev/null +++ b/nginx/nginx.conf @@ -0,0 +1,31 @@ +worker_processes 1; + +events { + worker_connections 1024; +} + +http { + server { + listen 8080; + server_name _; + + root /usr/share/nginx/html; + index index.html index.htm; + include /etc/nginx/mime.types; + + gzip on; + gzip_min_length 1000; + gzip_proxied expired no-cache no-store private auth; + gzip_types text/plain text/css application/json application/javascript application/x-javascript text/xml application/xml application/xml+rss text/javascript; + + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + internal; + } + + location / { + try_files $uri $uri/index.html =404; + } + } +} \ No newline at end of file diff --git a/src/pages/[lang]/Legal/Cookies.astro b/src/pages/[lang]/Legal/Cookies.astro index e754dec..7f3050f 100644 --- a/src/pages/[lang]/Legal/Cookies.astro +++ b/src/pages/[lang]/Legal/Cookies.astro @@ -2,7 +2,7 @@ import type {GetStaticPaths} from "astro"; import LegalLayout from "../../../layouts/LegalLayout.astro"; import getTranslatedContent from "../../../utils/directus.ts"; -import "./legal.scss"; +import "./Legal.scss"; const {lang} = Astro.params; const content = await getTranslatedContent("Cookie_Policy", lang!); diff --git a/src/pages/[lang]/Legal/Privacy.astro b/src/pages/[lang]/Legal/Privacy.astro index 7901368..e6dad7d 100644 --- a/src/pages/[lang]/Legal/Privacy.astro +++ b/src/pages/[lang]/Legal/Privacy.astro @@ -2,7 +2,7 @@ import type {GetStaticPaths} from "astro"; import LegalLayout from "../../../layouts/LegalLayout.astro"; import getTranslatedContent from "../../../utils/directus.ts"; -import "./legal.scss"; +import "./Legal.scss"; const {lang} = Astro.params; const content = await getTranslatedContent("Privacy_Policy", lang!); diff --git a/src/pages/[lang]/Legal/Terms.astro b/src/pages/[lang]/Legal/Terms.astro index 45f4751..95720e8 100644 --- a/src/pages/[lang]/Legal/Terms.astro +++ b/src/pages/[lang]/Legal/Terms.astro @@ -2,7 +2,7 @@ import type { GetStaticPaths } from "astro"; import LegalLayout from "../../../layouts/LegalLayout.astro"; import getTranslatedContent from "../../../utils/directus.ts"; -import "./legal.scss"; +import "./Legal.scss"; const {lang} = Astro.params; const content = await getTranslatedContent("Terms_Conditions", lang!); From 6b13b54a41448ea625fab31f239790c7d4a7ae12 Mon Sep 17 00:00:00 2001 From: Lennart Krauch Date: Thu, 21 Dec 2023 10:36:04 +0100 Subject: [PATCH 2/4] Fix indentation in CI.yaml file --- .github/workflows/CI.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 4e7b11c..ba066d3 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -69,5 +69,5 @@ jobs: tags: ${{ steps.meta-landing-page.outputs.tags }} labels: ${{ steps.meta-landing-page.outputs.labels }} build-args: | - DIRECTUS_URL = ${{ secrets.DIRECTUS_URL }} - DIRECTUS_TOKEN = ${{ secrets.DIRECTUS_TOKEN }} \ No newline at end of file + DIRECTUS_URL = ${{ secrets.DIRECTUS_URL }} + DIRECTUS_TOKEN = ${{ secrets.DIRECTUS_TOKEN }} \ No newline at end of file From b4d2ba7a350b373a6587cfd9efbae37e3ed92d57 Mon Sep 17 00:00:00 2001 From: Lennart Krauch Date: Thu, 21 Dec 2023 10:47:26 +0100 Subject: [PATCH 3/4] fix build args --- .github/workflows/CI.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index ba066d3..3c4463a 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -69,5 +69,5 @@ jobs: tags: ${{ steps.meta-landing-page.outputs.tags }} labels: ${{ steps.meta-landing-page.outputs.labels }} build-args: | - DIRECTUS_URL = ${{ secrets.DIRECTUS_URL }} - DIRECTUS_TOKEN = ${{ secrets.DIRECTUS_TOKEN }} \ No newline at end of file + DIRECTUS_URL=${{ secrets.DIRECTUS_URL }} + DIRECTUS_TOKEN=${{ secrets.DIRECTUS_TOKEN }} \ No newline at end of file From 272c7c399ab547f49a71625372ce0a44f824640d Mon Sep 17 00:00:00 2001 From: Lennart Krauch Date: Mon, 1 Jan 2024 04:38:02 +0100 Subject: [PATCH 4/4] fixed build only running on main --- .github/workflows/CI.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 3c4463a..e955dc7 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -23,8 +23,11 @@ jobs: - name: Code Linting run: npm run lint + build: name: Build + if: github.ref == 'refs/heads/main' && success() + needs: linting runs-on: ubuntu-latest steps: - name: Checkout