From babb807a914c4261e914479e74c2de3b105437b8 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 13:32:34 -0800 Subject: [PATCH 01/19] Add deployment workflow --- .gitea/workflows/deploy.yml | 144 ++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100644 .gitea/workflows/deploy.yml diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..21c3b0d --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,144 @@ +name: Build and deploy website. +on: + push: + # paths: + # - "content/**" + # - "static/**" + # - "templates/**" + branches: + - "master" + - "gdb.lgbtqi.app-production" + +jobs: + job1: + name: Build static site, docker image, upload artifact... + runs-on: catthehacker-ubuntu + steps: + - + name: Get current date + id: date + run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" + - + name: Checkout the git repo... + uses: actions/checkout@v3 + with: + ref: master + - + name: Set up docker buildx... + uses: docker/setup-buildx-action@v3 + - + name: Login to gitea registry + uses: docker/login-action@v3 + with: + registry: gitea.raer.me + username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} + password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} + - + name: Install required system packages... + run: | + export DEBIAN_FRONTEND=noninteractive + apt update + apt upgrade -y + apt install -y curl tar p7zip-full graphicsmagick + - + name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v2 + with: + node-version: '14' + cache: 'npm' + - + name: Restore node_modules cache + uses: actions/cache@v2 + with: + path: node_modules + key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node_modules + - + name: Restore Asset Cache + uses: actions/cache@v2 + with: + key: if-cache + path: | + ./if-cache/* + ./if-cache.json + ./twitter-cache.json + - + name: Install node dependencies + run: npm ci + - + name: Lint JS code + run: npm test + - + name: Build site + run: npm run build + - + name: Create artifact... + run: 7z a -mx=9 ./artifact.7z dist + - + name: Upload artifact... + uses: actions/upload-artifact@v3 + with: + name: artifact_${{ steps.date.outputs.date }} + path: ./artifact.7z + retention-days: 7 + - + uses: actions/checkout@v4 + with: + ref: gdb.lgbtqi.app-production + - + name: Build and push docker image to gitea package store + uses: docker/build-push-action@v5 + with: + context: . + push: true + platforms: linux/amd64 + tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} + job2: + needs: job1 + name: Connect to deployment host, update, and redeploy docs website. + runs-on: ubuntu-latest + steps: + - + name: Install required system packages... + run: | + export DEBIAN_FRONTEND=noninteractive + apt update + apt upgrade -y + apt install -y iputils-ping + - + name: Configure SSH... + env: + SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} + SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} + SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} + run: | + mkdir -p ~/.ssh/ + echo "$SSH_KEY" > ~/.ssh/staging.key + chmod 600 ~/.ssh/staging.key + cat >> ~/.ssh/config < Date: Thu, 8 Feb 2024 13:58:52 -0800 Subject: [PATCH 02/19] test ci --- .docker/.conf/nginx/conf.d/http/main.conf | 8 + .docker/.conf/nginx/nginx.conf | 69 +++++++++ .docker/.conf/nginx/snippets/fastcgi.conf | 26 ++++ .docker/.conf/nginx/snippets/mime-types.conf | 48 ++++++ .docker/.conf/nginx/snippets/proxy.conf | 10 ++ .docker/.conf/nginx/snippets/scgi.conf | 17 +++ .docker/.conf/nginx/snippets/uwsgi.conf | 17 +++ .docker/.conf/supervisor/supervisord.conf | 15 ++ .docker/Dockerfile | 15 ++ .gitea/workflows/deploy.yml | 151 +++++++------------ .github/FUNDING.yml | 3 - .github/dependabot.yml | 11 -- .github/workflows/build.yml | 108 ------------- 13 files changed, 278 insertions(+), 220 deletions(-) create mode 100644 .docker/.conf/nginx/conf.d/http/main.conf create mode 100644 .docker/.conf/nginx/nginx.conf create mode 100644 .docker/.conf/nginx/snippets/fastcgi.conf create mode 100644 .docker/.conf/nginx/snippets/mime-types.conf create mode 100644 .docker/.conf/nginx/snippets/proxy.conf create mode 100644 .docker/.conf/nginx/snippets/scgi.conf create mode 100644 .docker/.conf/nginx/snippets/uwsgi.conf create mode 100644 .docker/.conf/supervisor/supervisord.conf create mode 100644 .docker/Dockerfile delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/dependabot.yml delete mode 100644 .github/workflows/build.yml diff --git a/.docker/.conf/nginx/conf.d/http/main.conf b/.docker/.conf/nginx/conf.d/http/main.conf new file mode 100644 index 0000000..09a29aa --- /dev/null +++ b/.docker/.conf/nginx/conf.d/http/main.conf @@ -0,0 +1,8 @@ +server { + listen 80; + location / { + root /var/www/build; + autoindex off; + try_files $uri $uri/ =404; + } +} diff --git a/.docker/.conf/nginx/nginx.conf b/.docker/.conf/nginx/nginx.conf new file mode 100644 index 0000000..eac684b --- /dev/null +++ b/.docker/.conf/nginx/nginx.conf @@ -0,0 +1,69 @@ +worker_processes 4; +pid /run/nginx.pid; + + +error_log /dev/stderr info; + + +events { + worker_connections 1024; + multi_accept off; +} + +http { + + + ## asynchronous input/output policy. + tcp_nopush on; + sendfile on; + + + ## Security policy + ssl_protocols TLSv1.3 TLSv1.2; + ssl_ciphers "EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH+aRSA+RC4 EECDH EDH+aRSA HIGH !RC4 !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS"; + server_tokens off; # disable server version response header. + add_header X-Content-Type-Options nosniff; # Disable sniffing + add_header X-Frame-Options SAMEORIGIN always; # Prevent clickjacking. + add_header "X-XSS-Protection" "1; mode=block"; # Prevent cross-site-scripting + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; # Force HSTS, prevent mitm attack between 301 redirect for http, and https server. + + + ## Log file policy. + log_format logformat '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + access_log /dev/stdout logformat; + + + ## Temp file policy. + client_body_temp_path /tmp/client_temp; + fastcgi_temp_path /tmp/fastcgi_temp; + uwsgi_temp_path /tmp/uwsgi_temp; + proxy_temp_path /tmp/proxy_temp; + scgi_temp_path /tmp/scgi_temp; + + + ## Buffer Policy. + client_body_buffer_size 1K; + client_header_buffer_size 1k; + client_max_body_size 1k; + large_client_header_buffers 2 1k; + + + ## Client timeout policy + client_body_timeout 10; + client_header_timeout 10; + keepalive_timeout 5 5; + send_timeout 10; + + + ## Default mime type. + include snippets/mime-types.conf; + default_type text/html; + + + ## http vhosts + include conf.d/http/*.conf; + + +} \ No newline at end of file diff --git a/.docker/.conf/nginx/snippets/fastcgi.conf b/.docker/.conf/nginx/snippets/fastcgi.conf new file mode 100644 index 0000000..091738c --- /dev/null +++ b/.docker/.conf/nginx/snippets/fastcgi.conf @@ -0,0 +1,26 @@ + +fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; +fastcgi_param QUERY_STRING $query_string; +fastcgi_param REQUEST_METHOD $request_method; +fastcgi_param CONTENT_TYPE $content_type; +fastcgi_param CONTENT_LENGTH $content_length; + +fastcgi_param SCRIPT_NAME $fastcgi_script_name; +fastcgi_param REQUEST_URI $request_uri; +fastcgi_param DOCUMENT_URI $document_uri; +fastcgi_param DOCUMENT_ROOT $document_root; +fastcgi_param SERVER_PROTOCOL $server_protocol; +fastcgi_param REQUEST_SCHEME $scheme; +fastcgi_param HTTPS $https if_not_empty; + +fastcgi_param GATEWAY_INTERFACE CGI/1.1; +fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + +fastcgi_param REMOTE_ADDR $remote_addr; +fastcgi_param REMOTE_PORT $remote_port; +fastcgi_param SERVER_ADDR $server_addr; +fastcgi_param SERVER_PORT $server_port; +fastcgi_param SERVER_NAME $server_name; + +# PHP only, required if PHP was built with --enable-force-cgi-redirect +fastcgi_param REDIRECT_STATUS 200; diff --git a/.docker/.conf/nginx/snippets/mime-types.conf b/.docker/.conf/nginx/snippets/mime-types.conf new file mode 100644 index 0000000..62bd4b6 --- /dev/null +++ b/.docker/.conf/nginx/snippets/mime-types.conf @@ -0,0 +1,48 @@ +types { + text/html html htm shtml; + text/css css; + text/xml xml rss; + image/gif gif; + image/jpeg jpeg jpg; + application/x-javascript js; + text/plain txt; + text/x-component htc; + text/mathml mml; + image/png png; + image/x-icon ico; + image/x-jng jng; + image/vnd.wap.wbmp wbmp; + application/java-archive jar war ear; + application/mac-binhex40 hqx; + application/pdf pdf; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/zip zip; + application/octet-stream deb; + application/octet-stream bin exe dll; + application/octet-stream dmg; + application/octet-stream eot; + application/octet-stream iso img; + application/octet-stream msi msp msm; + audio/mpeg mp3; + audio/x-realaudio ra; + video/mpeg mpeg mpg; + video/quicktime mov; + video/x-flv flv; + video/x-msvideo avi; + video/x-ms-wmv wmv; + video/x-ms-asf asx asf; + video/x-mng mng; +} \ No newline at end of file diff --git a/.docker/.conf/nginx/snippets/proxy.conf b/.docker/.conf/nginx/snippets/proxy.conf new file mode 100644 index 0000000..34af2fe --- /dev/null +++ b/.docker/.conf/nginx/snippets/proxy.conf @@ -0,0 +1,10 @@ +proxy_redirect off; +proxy_set_header Host $host; +proxy_set_header X-Real-IP $remote_addr; +proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; +client_max_body_size 10m; +client_body_buffer_size 128k; +proxy_connect_timeout 90; +proxy_send_timeout 90; +proxy_read_timeout 90; +proxy_buffers 32 4k; \ No newline at end of file diff --git a/.docker/.conf/nginx/snippets/scgi.conf b/.docker/.conf/nginx/snippets/scgi.conf new file mode 100644 index 0000000..6d4ce4f --- /dev/null +++ b/.docker/.conf/nginx/snippets/scgi.conf @@ -0,0 +1,17 @@ + +scgi_param REQUEST_METHOD $request_method; +scgi_param REQUEST_URI $request_uri; +scgi_param QUERY_STRING $query_string; +scgi_param CONTENT_TYPE $content_type; + +scgi_param DOCUMENT_URI $document_uri; +scgi_param DOCUMENT_ROOT $document_root; +scgi_param SCGI 1; +scgi_param SERVER_PROTOCOL $server_protocol; +scgi_param REQUEST_SCHEME $scheme; +scgi_param HTTPS $https if_not_empty; + +scgi_param REMOTE_ADDR $remote_addr; +scgi_param REMOTE_PORT $remote_port; +scgi_param SERVER_PORT $server_port; +scgi_param SERVER_NAME $server_name; diff --git a/.docker/.conf/nginx/snippets/uwsgi.conf b/.docker/.conf/nginx/snippets/uwsgi.conf new file mode 100644 index 0000000..09c732c --- /dev/null +++ b/.docker/.conf/nginx/snippets/uwsgi.conf @@ -0,0 +1,17 @@ + +uwsgi_param QUERY_STRING $query_string; +uwsgi_param REQUEST_METHOD $request_method; +uwsgi_param CONTENT_TYPE $content_type; +uwsgi_param CONTENT_LENGTH $content_length; + +uwsgi_param REQUEST_URI $request_uri; +uwsgi_param PATH_INFO $document_uri; +uwsgi_param DOCUMENT_ROOT $document_root; +uwsgi_param SERVER_PROTOCOL $server_protocol; +uwsgi_param REQUEST_SCHEME $scheme; +uwsgi_param HTTPS $https if_not_empty; + +uwsgi_param REMOTE_ADDR $remote_addr; +uwsgi_param REMOTE_PORT $remote_port; +uwsgi_param SERVER_PORT $server_port; +uwsgi_param SERVER_NAME $server_name; diff --git a/.docker/.conf/supervisor/supervisord.conf b/.docker/.conf/supervisor/supervisord.conf new file mode 100644 index 0000000..11c40b8 --- /dev/null +++ b/.docker/.conf/supervisor/supervisord.conf @@ -0,0 +1,15 @@ +[supervisord] +nodaemon=true +logfile=/dev/null +logfile_maxbytes=0 +pidfile=/run/supervisord.pid + + +[program:nginx] +command=nginx -g 'daemon off;' +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +autorestart=true +startretries=3 diff --git a/.docker/Dockerfile b/.docker/Dockerfile new file mode 100644 index 0000000..a1940b5 --- /dev/null +++ b/.docker/Dockerfile @@ -0,0 +1,15 @@ +#### +## +## Build a docker image out of the static html book generated by mdbook. +## Used by automation. Can be built manually for testing. +## +#### +FROM alpine:3.17 +RUN apk add nginx supervisor +RUN mkdir -p /var/www +RUN rm -rf /etc/nginx +COPY build /var/www/build +COPY .conf/nginx /etc/nginx +COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf +CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] +EXPOSE 80 \ No newline at end of file diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 21c3b0d..4808604 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -7,11 +7,11 @@ on: # - "templates/**" branches: - "master" - - "gdb.lgbtqi.app-production" + - "ci-testing" jobs: job1: - name: Build static site, docker image, upload artifact... + name: Build static site. runs-on: catthehacker-ubuntu steps: - @@ -21,48 +21,18 @@ jobs: - name: Checkout the git repo... uses: actions/checkout@v3 - with: - ref: master - - - name: Set up docker buildx... - uses: docker/setup-buildx-action@v3 - - - name: Login to gitea registry - uses: docker/login-action@v3 - with: - registry: gitea.raer.me - username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} - password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} - name: Install required system packages... run: | export DEBIAN_FRONTEND=noninteractive apt update apt upgrade -y - apt install -y curl tar p7zip-full graphicsmagick + apt install -y curl graphicsmagick - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 with: node-version: '14' - cache: 'npm' - - - name: Restore node_modules cache - uses: actions/cache@v2 - with: - path: node_modules - key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node_modules - - - name: Restore Asset Cache - uses: actions/cache@v2 - with: - key: if-cache - path: | - ./if-cache/* - ./if-cache.json - ./twitter-cache.json - name: Install node dependencies run: npm ci @@ -72,73 +42,58 @@ jobs: - name: Build site run: npm run build - - - name: Create artifact... - run: 7z a -mx=9 ./artifact.7z dist - name: Upload artifact... - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: artifact_${{ steps.date.outputs.date }} - path: ./artifact.7z + name: build_artifact + path: dist retention-days: 7 - - - uses: actions/checkout@v4 - with: - ref: gdb.lgbtqi.app-production - - - name: Build and push docker image to gitea package store - uses: docker/build-push-action@v5 - with: - context: . - push: true - platforms: linux/amd64 - tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} - job2: - needs: job1 - name: Connect to deployment host, update, and redeploy docs website. - runs-on: ubuntu-latest - steps: - - - name: Install required system packages... - run: | - export DEBIAN_FRONTEND=noninteractive - apt update - apt upgrade -y - apt install -y iputils-ping - - - name: Configure SSH... - env: - SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} - SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} - SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} - run: | - mkdir -p ~/.ssh/ - echo "$SSH_KEY" > ~/.ssh/staging.key - chmod 600 ~/.ssh/staging.key - cat >> ~/.ssh/config < ~/.ssh/staging.key + # chmod 600 ~/.ssh/staging.key + # cat >> ~/.ssh/config < Date: Thu, 8 Feb 2024 14:02:36 -0800 Subject: [PATCH 03/19] Attempt to Fix issue in ci... --- .gitea/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 4808604..6419470 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -12,7 +12,7 @@ on: jobs: job1: name: Build static site. - runs-on: catthehacker-ubuntu + runs-on: ubuntu-latest steps: - name: Get current date @@ -44,7 +44,7 @@ jobs: run: npm run build - name: Upload artifact... - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v3 with: name: build_artifact path: dist From 8267c5f345455dda72acb4684a5ae4cb34668477 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:12:50 -0800 Subject: [PATCH 04/19] Test ci changes... --- .gitea/workflows/deploy.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 6419470..87565fc 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -27,7 +27,7 @@ jobs: export DEBIAN_FRONTEND=noninteractive apt update apt upgrade -y - apt install -y curl graphicsmagick + apt install -y graphicsmagick - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 @@ -49,6 +49,18 @@ jobs: name: build_artifact path: dist retention-days: 7 + job2: + needs: job1 + name: Build new docker container with new site build... + runs-on: catthehacker-ubuntu + steps: + - + name: Download artifact... + uses: actions/download-artifact@v3 + with: + path: dist + - + run: ls -R my-artifact # job2: # needs: job1 # name: Connect to deployment host, update, and redeploy docs website. From feca9646db0cd665bac838a4fc71af4a39ee6e4d Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:13:40 -0800 Subject: [PATCH 05/19] fix issue --- .gitea/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 87565fc..e5bdf08 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -60,7 +60,8 @@ jobs: with: path: dist - - run: ls -R my-artifact + run: ls -R dist + # job2: # needs: job1 # name: Connect to deployment host, update, and redeploy docs website. From 14e74374fa23550c4bca02852b81470aae9efa37 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:23:50 -0800 Subject: [PATCH 06/19] Test new ci --- .docker/Dockerfile | 2 +- .gitea/workflows/deploy.yml | 44 +++++++++++++++++++++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a1940b5..b303239 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -8,7 +8,7 @@ FROM alpine:3.17 RUN apk add nginx supervisor RUN mkdir -p /var/www RUN rm -rf /etc/nginx -COPY build /var/www/build +COPY /dist /var/www/build COPY .conf/nginx /etc/nginx COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e5bdf08..5d5b534 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -21,13 +21,15 @@ jobs: - name: Checkout the git repo... uses: actions/checkout@v3 + with: + ref: master - name: Install required system packages... run: | export DEBIAN_FRONTEND=noninteractive apt update apt upgrade -y - apt install -y graphicsmagick + apt install -y graphicsmagick p7zip-full - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v2 @@ -42,25 +44,59 @@ jobs: - name: Build site run: npm run build + - + name: Create artifact... + run: 7z a -mx=9 /artifact.7z dist - name: Upload artifact... uses: actions/upload-artifact@v3 with: name: build_artifact - path: dist + path: /artifact.7z retention-days: 7 job2: needs: job1 name: Build new docker container with new site build... runs-on: catthehacker-ubuntu steps: + - + name: Install required system packages... + run: | + export DEBIAN_FRONTEND=noninteractive + apt update + apt upgrade -y + apt install -y p7zip-full - name: Download artifact... uses: actions/download-artifact@v3 with: - path: dist + path: /dist.7z - - run: ls -R dist + run: | + 7z x /dist.7z /dist; ls /dist + # - + # name: Checkout the docker build branch... + # uses: actions/checkout@v3 + # with: + # ref: ci-testing + # - + # name: Set up docker buildx... + # uses: docker/setup-buildx-action@v3 + # - + # name: Login to gitea registry + # uses: docker/login-action@v3 + # with: + # registry: gitea.raer.me + # username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} + # password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} + # - + # name: Build and push docker image to gitea package store + # uses: docker/build-push-action@v5 + # with: + # context: .docker/Dockerfile + # push: true + # platforms: linux/amd64 + # tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} # job2: # needs: job1 From 49ac8f3afd91e692e375f06537c571bfd8f2a6f5 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:29:33 -0800 Subject: [PATCH 07/19] update ci --- .gitea/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 5d5b534..81f1359 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -70,10 +70,10 @@ jobs: name: Download artifact... uses: actions/download-artifact@v3 with: - path: /dist.7z + path: / - run: | - 7z x /dist.7z /dist; ls /dist + 7z x /build_artifact/artifact.7z /dist; ls /dist # - # name: Checkout the docker build branch... # uses: actions/checkout@v3 From db98223acae6338f1b6687fbd9a0d24d8755cb81 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:37:34 -0800 Subject: [PATCH 08/19] Test new ci process... --- .docker/Dockerfile | 2 +- .gitea/workflows/deploy.yml | 181 +++++++++++++++++++++--------------- 2 files changed, 105 insertions(+), 78 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index b303239..1297372 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -8,7 +8,7 @@ FROM alpine:3.17 RUN apk add nginx supervisor RUN mkdir -p /var/www RUN rm -rf /etc/nginx -COPY /dist /var/www/build +COPY dist /var/www/build COPY .conf/nginx /etc/nginx COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 81f1359..c63af57 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -23,6 +23,12 @@ jobs: uses: actions/checkout@v3 with: ref: master + - + name: Checkout the docker build branch... + uses: actions/checkout@v3 + with: + ref: ci-testing + path: /docker - name: Install required system packages... run: | @@ -44,37 +50,58 @@ jobs: - name: Build site run: npm run build - - - name: Create artifact... - run: 7z a -mx=9 /artifact.7z dist - - - name: Upload artifact... - uses: actions/upload-artifact@v3 - with: - name: build_artifact - path: /artifact.7z - retention-days: 7 - job2: - needs: job1 - name: Build new docker container with new site build... - runs-on: catthehacker-ubuntu - steps: - - - name: Install required system packages... - run: | - export DEBIAN_FRONTEND=noninteractive - apt update - apt upgrade -y - apt install -y p7zip-full - - - name: Download artifact... - uses: actions/download-artifact@v3 - with: - path: / - - - run: | - 7z x /build_artifact/artifact.7z /dist; ls /dist # - + # name: Create artifact... + # run: 7z a -mx=9 ./artifact.7z dist + # - + # name: Upload artifact... + # uses: actions/upload-artifact@v3 + # with: + # name: build_artifact + # path: dist + # retention-days: 7 + - + name: Copy dist to docker... + run: cp -a dist /docker/dist + - + name: Set up docker buildx... + uses: docker/setup-buildx-action@v3 + - + name: Login to gitea registry + uses: docker/login-action@v3 + with: + registry: gitea.raer.me + username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} + password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} + - + name: Build and push docker image to gitea package store + uses: docker/build-push-action@v5 + with: + context: /docker/.docker/Dockerfile + push: true + platforms: linux/amd64 + tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} + # job2: + # needs: job1 + # name: Build new docker container with new site build... + # runs-on: catthehacker-ubuntu + # steps: + # - + # name: Install required system packages... + # run: | + # export DEBIAN_FRONTEND=noninteractive + # apt update + # apt upgrade -y + # apt install -y p7zip-full + # - + # name: Download artifact... + # uses: actions/download-artifact@v3 + # with: + # path: / + # - + # run: | + # 7z x /build_artifact/artifact.7z /dist; ls /dist + # # - # name: Checkout the docker build branch... # uses: actions/checkout@v3 # with: @@ -98,51 +125,51 @@ jobs: # platforms: linux/amd64 # tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} - # job2: - # needs: job1 - # name: Connect to deployment host, update, and redeploy docs website. - # runs-on: ubuntu-latest - # steps: - # - - # name: Install required system packages... - # run: | - # export DEBIAN_FRONTEND=noninteractive - # apt update - # apt upgrade -y - # apt install -y iputils-ping - # - - # name: Configure SSH... - # env: - # SSH_USER: ${{ secrets.PRODUCTION_SSH_USER }} - # SSH_KEY: ${{ secrets.PRODUCTION_SSH_KEY }} - # SSH_HOST: ${{ secrets.PRODUCTION_SSH_HOST }} - # run: | - # mkdir -p ~/.ssh/ - # echo "$SSH_KEY" > ~/.ssh/staging.key - # chmod 600 ~/.ssh/staging.key - # cat >> ~/.ssh/config < ~/.ssh/staging.key + chmod 600 ~/.ssh/staging.key + cat >> ~/.ssh/config < Date: Thu, 8 Feb 2024 14:39:59 -0800 Subject: [PATCH 09/19] Fix ci... (hopefully) --- .gitea/workflows/deploy.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index c63af57..646330c 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v3 with: ref: ci-testing - path: /docker + path: docker - name: Install required system packages... run: | @@ -62,7 +62,7 @@ jobs: # retention-days: 7 - name: Copy dist to docker... - run: cp -a dist /docker/dist + run: cp -a dist docker/ - name: Set up docker buildx... uses: docker/setup-buildx-action@v3 @@ -77,7 +77,7 @@ jobs: name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 with: - context: /docker/.docker/Dockerfile + context: docker/.docker/Dockerfile push: true platforms: linux/amd64 tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} From 98c346572b33d3f0eae6bac0bbc35d8e6000a7eb Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:44:27 -0800 Subject: [PATCH 10/19] FIX --- .gitea/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 646330c..04dc7f0 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -12,7 +12,7 @@ on: jobs: job1: name: Build static site. - runs-on: ubuntu-latest + runs-on: catthehacker-ubuntu steps: - name: Get current date From 0712a89acec057aa7d007999a0ce078fcda663bb Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:45:55 -0800 Subject: [PATCH 11/19] fix dockerfile --- .docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 1297372..a154703 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -8,7 +8,7 @@ FROM alpine:3.17 RUN apk add nginx supervisor RUN mkdir -p /var/www RUN rm -rf /etc/nginx -COPY dist /var/www/build +COPY ../dist /var/www/build COPY .conf/nginx /etc/nginx COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] From 98c86938a9644f8ecb8d065bfb29e0aeccf1de7d Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 14:51:12 -0800 Subject: [PATCH 12/19] Fix ci --- .gitea/workflows/deploy.yml | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 04dc7f0..2a1d3a5 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -18,6 +18,16 @@ jobs: name: Get current date id: date run: echo "::set-output name=date::$(date +'%Y%m%d%H%M%S')" + - + name: Set up docker buildx... + uses: docker/setup-buildx-action@v3 + - + name: Login to gitea registry + uses: docker/login-action@v3 + with: + registry: gitea.raer.me + username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} + password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} - name: Checkout the git repo... uses: actions/checkout@v3 @@ -50,29 +60,9 @@ jobs: - name: Build site run: npm run build - # - - # name: Create artifact... - # run: 7z a -mx=9 ./artifact.7z dist - # - - # name: Upload artifact... - # uses: actions/upload-artifact@v3 - # with: - # name: build_artifact - # path: dist - # retention-days: 7 - name: Copy dist to docker... - run: cp -a dist docker/ - - - name: Set up docker buildx... - uses: docker/setup-buildx-action@v3 - - - name: Login to gitea registry - uses: docker/login-action@v3 - with: - registry: gitea.raer.me - username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} - password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} + run: npm cache clean;cp -a dist docker/ - name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 @@ -81,6 +71,16 @@ jobs: push: true platforms: linux/amd64 tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} + - + name: Create artifact... + run: 7z a -mx=9 artifact.7z dist + - + name: Upload artifact... + uses: actions/upload-artifact@v3 + with: + name: build_artifact + path: artifact.7z + retention-days: 7 # job2: # needs: job1 # name: Build new docker container with new site build... From 4b3599d7006cbfcf99fe0d4417f1c09e9dda49a0 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:00:09 -0800 Subject: [PATCH 13/19] fuck --- .gitea/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 2a1d3a5..e88efb0 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -62,7 +62,7 @@ jobs: run: npm run build - name: Copy dist to docker... - run: npm cache clean;cp -a dist docker/ + run: npm cache clean --force;cp -a dist docker/ - name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 From bc23eb3a10d03110eda3ec0420fbc86e2725212e Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:07:56 -0800 Subject: [PATCH 14/19] fix please? maybe? --- .docker/Dockerfile | 2 +- .gitea/workflows/deploy.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index a154703..3df2594 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -8,7 +8,7 @@ FROM alpine:3.17 RUN apk add nginx supervisor RUN mkdir -p /var/www RUN rm -rf /etc/nginx -COPY ../dist /var/www/build +COPY ../build /var/www/build COPY .conf/nginx /etc/nginx COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e88efb0..2d5c1a1 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -47,7 +47,7 @@ jobs: apt upgrade -y apt install -y graphicsmagick p7zip-full - - name: Use Node.js ${{ matrix.node-version }} + name: Use Node.js uses: actions/setup-node@v2 with: node-version: '14' @@ -62,7 +62,7 @@ jobs: run: npm run build - name: Copy dist to docker... - run: npm cache clean --force;cp -a dist docker/ + run: npm cache clean --force;mv dist docker/build - name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 From bd5f7b6146cb01111b4bffcc83e83f2ada55cb82 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:13:13 -0800 Subject: [PATCH 15/19] fix --- .gitea/workflows/deploy.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 2d5c1a1..e6e7953 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -63,6 +63,11 @@ jobs: - name: Copy dist to docker... run: npm cache clean --force;mv dist docker/build + - + name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '20' - name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 From 38c1622d37850e8d301198ea798d91ad908c6263 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:18:06 -0800 Subject: [PATCH 16/19] fixxxxx --- .gitea/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index e6e7953..b0aaa38 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -72,7 +72,7 @@ jobs: name: Build and push docker image to gitea package store uses: docker/build-push-action@v5 with: - context: docker/.docker/Dockerfile + context: docker/.docker push: true platforms: linux/amd64 tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} From e11ec137093f38691ac0d34e88c605af2bac6474 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:22:40 -0800 Subject: [PATCH 17/19] Fix ci finally? --- .docker/Dockerfile | 2 +- .gitea/workflows/deploy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.docker/Dockerfile b/.docker/Dockerfile index 3df2594..1297372 100644 --- a/.docker/Dockerfile +++ b/.docker/Dockerfile @@ -8,7 +8,7 @@ FROM alpine:3.17 RUN apk add nginx supervisor RUN mkdir -p /var/www RUN rm -rf /etc/nginx -COPY ../build /var/www/build +COPY dist /var/www/build COPY .conf/nginx /etc/nginx COPY .conf/supervisor/supervisord.conf /etc/supervisor/conf.d/supervisord.conf CMD ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"] diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index b0aaa38..dd6ac9e 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -62,7 +62,7 @@ jobs: run: npm run build - name: Copy dist to docker... - run: npm cache clean --force;mv dist docker/build + run: npm cache clean --force;mv dist docker/.docker/dist - name: Use Node.js uses: actions/setup-node@v2 From ea864719125b1ce674499d9ec0ee48d537bbf214 Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:25:30 -0800 Subject: [PATCH 18/19] FIX?? --- .gitea/workflows/deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index dd6ac9e..71a080a 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -8,6 +8,7 @@ on: branches: - "master" - "ci-testing" + - "production" jobs: job1: @@ -62,7 +63,7 @@ jobs: run: npm run build - name: Copy dist to docker... - run: npm cache clean --force;mv dist docker/.docker/dist + run: npm cache clean --force;cp -a dist docker/.docker/dist - name: Use Node.js uses: actions/setup-node@v2 From 46a8c1a5356716fd21dd612d9850de2620cedf8c Mon Sep 17 00:00:00 2001 From: Freyja Odinthrir Date: Thu, 8 Feb 2024 15:35:11 -0800 Subject: [PATCH 19/19] production branch. --- .gitea/workflows/deploy.yml | 50 +------------------------------------ 1 file changed, 1 insertion(+), 49 deletions(-) diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 71a080a..3c86037 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -1,13 +1,8 @@ name: Build and deploy website. on: push: - # paths: - # - "content/**" - # - "static/**" - # - "templates/**" branches: - "master" - - "ci-testing" - "production" jobs: @@ -38,7 +33,7 @@ jobs: name: Checkout the docker build branch... uses: actions/checkout@v3 with: - ref: ci-testing + ref: production path: docker - name: Install required system packages... @@ -87,49 +82,6 @@ jobs: name: build_artifact path: artifact.7z retention-days: 7 - # job2: - # needs: job1 - # name: Build new docker container with new site build... - # runs-on: catthehacker-ubuntu - # steps: - # - - # name: Install required system packages... - # run: | - # export DEBIAN_FRONTEND=noninteractive - # apt update - # apt upgrade -y - # apt install -y p7zip-full - # - - # name: Download artifact... - # uses: actions/download-artifact@v3 - # with: - # path: / - # - - # run: | - # 7z x /build_artifact/artifact.7z /dist; ls /dist - # # - - # name: Checkout the docker build branch... - # uses: actions/checkout@v3 - # with: - # ref: ci-testing - # - - # name: Set up docker buildx... - # uses: docker/setup-buildx-action@v3 - # - - # name: Login to gitea registry - # uses: docker/login-action@v3 - # with: - # registry: gitea.raer.me - # username: ${{ secrets.PRODUCTION_REGISTRY_USERNAME }} - # password: ${{ secrets.PRODUCTION_REGISTRY_TOKEN }} - # - - # name: Build and push docker image to gitea package store - # uses: docker/build-push-action@v5 - # with: - # context: .docker/Dockerfile - # push: true - # platforms: linux/amd64 - # tags: gitea.raer.me/${{ gitea.repository }}:${{ gitea.ref_name }} job2: needs: job1