From 535e76bfef2ee0aaa8278b4d29cd55d59aa223cf Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Tue, 29 Apr 2025 13:26:43 +0200 Subject: [PATCH] wait in correct system, serve admin via mini webserver also --- .github/workflows/test_e2e.yml | 8 ++++---- admin/Dockerfile | 8 ++------ nginx/e2e-test.conf | 33 +++++++++++++++++++++++++++++++++ nginx/serve.conf | 30 ------------------------------ nginx/serveAdmin.conf | 29 ----------------------------- 5 files changed, 39 insertions(+), 69 deletions(-) create mode 100644 nginx/e2e-test.conf delete mode 100644 nginx/serve.conf delete mode 100644 nginx/serveAdmin.conf diff --git a/.github/workflows/test_e2e.yml b/.github/workflows/test_e2e.yml index 6d1311cb9..3de81644f 100644 --- a/.github/workflows/test_e2e.yml +++ b/.github/workflows/test_e2e.yml @@ -20,7 +20,7 @@ jobs: run: | sudo chown runner:docker -R * bun install - sudo cp ./nginx/gradido.conf /etc/nginx/sites-available/default + sudo cp ./nginx/e2e-test.conf /etc/nginx/sites-available/default - name: wait for database to be ready run: docker run --rm --network gradido_internal-net busybox sh -c 'until nc -z mariadb 3306; do echo waiting for db; sleep 1; done;' @@ -45,8 +45,8 @@ jobs: - name: wait for frontend and backend to be ready run: | - docker run --rm --network gradido_internal-net busybox sh -c 'until nc -z 127.0.0.1 3000; do echo waiting for frontend; sleep 1; done;' - docker run --rm --network gradido_internal-net busybox sh -c 'until nc -z 127.0.0.1 4000; do echo waiting for backend; sleep 1; done;' + until nc -z 127.0.0.1 3000; do echo waiting for frontend; sleep 1; done; + until nc -z 127.0.0.1 4000; do echo waiting for backend; sleep 1; done; - name: Start local nginx webserver run: | @@ -54,7 +54,7 @@ jobs: sudo systemctl start nginx - name: wait for nginx to be ready - run: docker run --rm --network gradido_internal-net busybox sh -c 'until nc -z 127.0.0.1 80; do echo waiting for nginx; sleep 1; done;' + run: until nc -z 127.0.0.1 80; do echo waiting for nginx; sleep 1; done; - name: End-to-end tests | run tests id: e2e-tests diff --git a/admin/Dockerfile b/admin/Dockerfile index df2335ded..ca5573502 100644 --- a/admin/Dockerfile +++ b/admin/Dockerfile @@ -90,14 +90,10 @@ CMD /bin/sh -c "turbo admin#test --env-mode=loose" ################################################################################## # PRODUCTION (Does contain only "binary"- and static-files to reduce image size) # ################################################################################## -FROM nginx:alpine as production +FROM lipanski/docker-static-website:latest as production # TODO: Improve size from 50 MB down to 2 MB with lipanski/docker-static-website:latest # https://lipanski.com/posts/smallest-docker-image-static-website # copy builded frontend files -COPY --from=installer /app/admin/build/ /usr/share/nginx/html/ - -# copy nginx config -COPY nginx/serveAdmin.conf /etc/nginx/conf.d/default.conf - +COPY --from=installer /app/admin/build/ ./admin/ diff --git a/nginx/e2e-test.conf b/nginx/e2e-test.conf new file mode 100644 index 000000000..682379b87 --- /dev/null +++ b/nginx/e2e-test.conf @@ -0,0 +1,33 @@ +server { + server_name _; + + listen 80; + listen [::]:80; + + # Frontend (default) + location / { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + + proxy_pass http://127.0.0.1:3000; + proxy_redirect off; + } + + # Backend + location /graphql { + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection 'upgrade'; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + + proxy_pass http://127.0.0.1:4000; + proxy_redirect off; + } + +} diff --git a/nginx/serve.conf b/nginx/serve.conf deleted file mode 100644 index e793fbfba..000000000 --- a/nginx/serve.conf +++ /dev/null @@ -1,30 +0,0 @@ -server { - listen 80; - server_name localhost; - - gzip_static on; - gzip on; - gzip_proxied any; - gzip_types - text/css - text/javascript - text/xml - text/plain - application/javascript - application/x-javascript - application/json; - - root /usr/share/nginx/html; - index index.html; - - location / { - #limit_req zone=frontend burst=40 nodelay; - #limit_conn addr 40; - root /usr/share/nginx/html/; - index index.html; - try_files $uri $uri/ /index.html = 404; - } - - # Optional: CORS Header (vorsichtig, je nach Bedarf) - add_header Access-Control-Allow-Origin *; -} \ No newline at end of file diff --git a/nginx/serveAdmin.conf b/nginx/serveAdmin.conf deleted file mode 100644 index 501366233..000000000 --- a/nginx/serveAdmin.conf +++ /dev/null @@ -1,29 +0,0 @@ -server { - listen 80; - server_name localhost; - - gzip_static on; - gzip on; - gzip_proxied any; - gzip_types - text/css - text/javascript - text/xml - text/plain - application/javascript - application/x-javascript - application/json; - - - location /admin { - #limit_req zone=frontend burst=30 nodelay; - #limit_conn addr 40; - rewrite ^/admin/(.*)$ /$1 break; - root /usr/share/nginx/html/; - index index.html; - try_files $uri $uri/ /index.html = 404; - } - - # Optional: CORS Header (vorsichtig, je nach Bedarf) - add_header Access-Control-Allow-Origin *; -} \ No newline at end of file