From 884db93707ee64f2dc176ef3706b1532af7bc0e4 Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 17:40:12 +0100 Subject: [PATCH 1/6] Add build and deploy workflow --- .github/workflows/build-and-deploy.yml | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/build-and-deploy.yml diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml new file mode 100644 index 0000000..976ebc4 --- /dev/null +++ b/.github/workflows/build-and-deploy.yml @@ -0,0 +1,46 @@ +name: Build and Deploy app + +on: + push: + branches: ["main"] + +concurrency: + group: ${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2.2.1 + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Frontend + uses: docker/build-push-action@v3 + with: + context: . + file: docker/frontend/Dockerfile + push: true + tags: "ghcr.io/${{ github.repository }}/frontend:latest" + + # - name: pull and start new image + # uses: appleboy/ssh-action@master + # with: + # host: ${{ secrets.HOST }} + # username: ${{ secrets.USER_NAME }} + # key: ${{ secrets.PRIVATE_KEY}} + # script: cd c4s-website && docker compose pull && docker compose up -d From 03837e6be22a4271889150034b68aafa90d0ae7c Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 17:54:22 +0100 Subject: [PATCH 2/6] Update build-and-deploy.yml with SSH action for pulling and starting new image --- .github/workflows/build-and-deploy.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml index 976ebc4..ecd9741 100644 --- a/.github/workflows/build-and-deploy.yml +++ b/.github/workflows/build-and-deploy.yml @@ -37,10 +37,10 @@ jobs: push: true tags: "ghcr.io/${{ github.repository }}/frontend:latest" - # - name: pull and start new image - # uses: appleboy/ssh-action@master - # with: - # host: ${{ secrets.HOST }} - # username: ${{ secrets.USER_NAME }} - # key: ${{ secrets.PRIVATE_KEY}} - # script: cd c4s-website && docker compose pull && docker compose up -d + - name: pull and start new image + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USER_NAME }} + key: ${{ secrets.PRIVATE_KEY}} + script: cd c4s-website && docker compose pull && docker compose up -d From 6ca2ecf0b6157f84e8ce854d25c116560c701f1a Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 18:05:07 +0100 Subject: [PATCH 3/6] Refactor Docker Compose and Nginx configuration --- docker-compose.example.yml | 17 ----------------- docker-compose.yml | 10 ++++++++++ docker/frontend/Dockerfile | 1 - docker/frontend/nginx.conf | 2 +- 4 files changed, 11 insertions(+), 19 deletions(-) delete mode 100644 docker-compose.example.yml create mode 100644 docker-compose.yml diff --git a/docker-compose.example.yml b/docker-compose.example.yml deleted file mode 100644 index ad303fd..0000000 --- a/docker-compose.example.yml +++ /dev/null @@ -1,17 +0,0 @@ -version: "3" - -services: - - frontend: - build: - context: ./ - dockerfile: "frontend.Dockerfile" - restart: always - volumes: - - ./nginx.conf:/etc/nginx/nginx.conf - expose: - - 8080 - ports: - - "8080:8080" - depends_on: - - api diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9e96424 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,10 @@ +version: "3" + +services: + frontend: + build: + context: . + dockerfile: "docker/frontend/Dockerfile" + restart: always + ports: + - "8080:8080" diff --git a/docker/frontend/Dockerfile b/docker/frontend/Dockerfile index 01870ec..2a04da2 100644 --- a/docker/frontend/Dockerfile +++ b/docker/frontend/Dockerfile @@ -11,7 +11,6 @@ RUN deno cache build.ts ADD . . RUN deno task build - # build nginx webserver FROM nginx:alpine diff --git a/docker/frontend/nginx.conf b/docker/frontend/nginx.conf index da89686..c308fd4 100644 --- a/docker/frontend/nginx.conf +++ b/docker/frontend/nginx.conf @@ -25,7 +25,7 @@ http { client_max_body_size 1m; server { - listen 8080 default_server; + listen 80 default_server; server_name _; location / { From f480d2ab1d6e7c2705a1639951aff3cbdcf997d7 Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 18:11:00 +0100 Subject: [PATCH 4/6] Update docker-compose.prod.yaml with Traefik configuration --- docker-compose.prod.yaml | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/docker-compose.prod.yaml b/docker-compose.prod.yaml index aa4f212..72aac5d 100644 --- a/docker-compose.prod.yaml +++ b/docker-compose.prod.yaml @@ -3,21 +3,17 @@ version: "3.7" networks: web: external: true - c4s-website: services: - app: image: ghcr.io/chaostreff-flensburg/c4s-website/frontend:latest - restart: unless-stopped + restart: always networks: - web - - c4s-website labels: - - traefik.enable=true - - traefik.http.routers.c4s-website.rule=Host(`42.ccc.de`) - - traefik.http.routers.c4s-website.entrypoints=websecure - - traefik.http.routers.c4s-website.tls=true - - traefik.http.routers.c4s-website.certresolver=le - - traefik.http.services.c4s-website.loadbalancer.server.port=8080 - - traefik.docker.network=web + - "traefik.enable=true" + - "traefik.http.routers.c4s-website.rule=Host(`42.ccc.de`)" + - "traefik.http.routers.c4s-website.entrypoints=https,http" + - "traefik.http.services.c4s-website.loadbalancer.server.port=80" + - "traefik.http.routers.c4s-website.tls.certresolver=mytlschallenge" + - "traefik.docker.network=web" From 31b1d7751e97747f0ecbeea96df673d16794282a Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 18:12:58 +0100 Subject: [PATCH 5/6] Update links in Footer component --- content/_components/Footer.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/_components/Footer.tsx b/content/_components/Footer.tsx index b73fb51..19a892f 100644 --- a/content/_components/Footer.tsx +++ b/content/_components/Footer.tsx @@ -3,17 +3,17 @@ export default ({ text }) => (

{text.footer_slogan}{" "} - Chaos Computer Club e.V. + Chaos Computer Club e.V.

- + {text.footer_imprint} {!text.footer_imprint && Impressum} {" "} &{" "} - + {text.footer_privacy} {!text.footer_privacy && Datenschutz} From e74e6858700b6cbd73df7c1f0f10fd68d06e2272 Mon Sep 17 00:00:00 2001 From: Flemming Petersen Date: Tue, 26 Dec 2023 18:14:37 +0100 Subject: [PATCH 6/6] Enable gzip compression in nginx.conf --- docker/frontend/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/frontend/nginx.conf b/docker/frontend/nginx.conf index c308fd4..7fc5dc5 100644 --- a/docker/frontend/nginx.conf +++ b/docker/frontend/nginx.conf @@ -20,7 +20,7 @@ http { # tcp_nopush on; keepalive_timeout 3; # tcp_nodelay on; -# gzip on; + gzip on; client_max_body_size 1m;