From 8e88fd8597ddbeff0e2689b410a06bc11be4d08b Mon Sep 17 00:00:00 2001 From: Firq Date: Wed, 20 Dec 2023 20:32:02 +0100 Subject: [PATCH] testing with dockerfile --- .forgejo/workflows/build_release.yml | 49 ++++++++++++ .forgejo/workflows/ci.yml | 110 --------------------------- .forgejo/workflows/linting.yml | 16 ++++ .forgejo/workflows/redeploy.yml | 31 -------- .vscode/settings.json | 3 +- Dockerfile | 16 ++++ public/favicon.svg | 9 --- 7 files changed, 83 insertions(+), 151 deletions(-) create mode 100644 .forgejo/workflows/build_release.yml delete mode 100644 .forgejo/workflows/ci.yml create mode 100644 .forgejo/workflows/linting.yml delete mode 100644 .forgejo/workflows/redeploy.yml create mode 100644 Dockerfile delete mode 100644 public/favicon.svg diff --git a/.forgejo/workflows/build_release.yml b/.forgejo/workflows/build_release.yml new file mode 100644 index 0000000..b393139 --- /dev/null +++ b/.forgejo/workflows/build_release.yml @@ -0,0 +1,49 @@ +on: + push: + tags: + - "\d+\.\d+\.\d+(?:(?:a|b|rc)\d+)?" + +jobs: + checking: + runs-on: docker + container: node:lts + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: npm install + - name: Run astro check (linting + static analysis) + run: npm run astro check + + build-site: + needs: [checking] + if: success() + runs-on: dind + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + registry: forgejo.neshweb.net + username: ${{ secrets.FORGEJO_USERNAME }} + password: ${{ secrets.FORGEJO_TOKEN }} + - name: Push to Package Registry + uses: docker/build-push-action@v5 + with: + push: true + tags: forgejo.neshweb.net/firq/fgo-ta.com-website:${{ github.ref_name }}, forgejo.neshweb.net/firq/fgo-ta.com-website:latest + + release: + needs: [build-site] + if: success() + runs-on: docker + steps: + - name: Release New Version + uses: actions/forgejo-release@v1 + with: + direction: upload + url: https://forgejo.neshweb.net + release-dir: release + token: ${{ secrets.FORGEJO_TOKEN }} + tag: ${{ github.ref_name }} diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml deleted file mode 100644 index b3ea3d4..0000000 --- a/.forgejo/workflows/ci.yml +++ /dev/null @@ -1,110 +0,0 @@ -on: - push: - branches: - - main - -jobs: - checking: - runs-on: docker - container: node:lts - steps: - - name: Checkout source code - uses: https://code.forgejo.org/actions/checkout@v3 - - name: Install packages - run: npm install - - name: Run astro check (linting + static analysis) - run: npm run astro check - - build-site: - needs: [checking] - runs-on: docker - container: node:lts - steps: - - name: Checkout checked source code - uses: https://code.forgejo.org/actions/checkout@v3 - - name: Install required packages - run: npm install - - name: Build static site - run: npm run build - - name: Delete unnecessary data files - run: rm -r public/assets/data/ - - name: Copy missing config for binserve - run: cp serve.json public - - name: Save site artifact as static-site - uses: https://code.forgejo.org/actions/upload-artifact@v3 - with: - name: static-site - path: public/ - - deploy-files: - needs: [ build-site ] - runs-on: docker - env: - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} - steps: - - name: Install and update ssh + rsync - run: | - which rsync || ( apt update -y && apt install rsync -y) - which ssh-agent || ( apt update -y && apt install openssh-client -y) - - name: Downloading static site artifacts - uses: actions/download-artifact@v3 - with: - name: static-site - path: public - - name: Install SSH Key - uses: https://github.com/shimataro/ssh-key-action@v2 - with: - key: ${{ secrets.SSH_PRIVATE_KEY }} - known_hosts: unnecessary - - name: Adding Known Hosts - run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - - name: Stop screen session, delete old files - uses: https://github.com/appleboy/ssh-action@master - with: - host: ${{ env.DEPLOY_HOST }} - username: ${{ env.DEPLOY_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - screen -X -S fgo-ta_com-public kill - rm -r -f fgo-ta_com/public/* - - name: Copy files using rsync - run: rsync -az --stats public/* ${{ env.DEPLOY_USER }}@${{ env.DEPLOY_HOST }}:~/fgo-ta_com/public - - name: Check files on deploy target - uses: https://github.com/appleboy/ssh-action@master - with: - host: ${{ env.DEPLOY_HOST }} - username: ${{ env.DEPLOY_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - cd fgo-ta_com - find public -maxdepth 1 -printf "%p\n" - - deploy-site: - needs: [ deploy-files ] - runs-on: docker - env: - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} - steps: - - name: Install and update ssh + rsync - run: | - which rsync || ( apt update -y && apt install rsync -y) - which ssh-agent || ( apt update -y && apt install openssh-client -y) - - name: Install SSH Key - uses: https://github.com/shimataro/ssh-key-action@v2 - with: - key: ${{ secrets.SSH_PRIVATE_KEY }} - known_hosts: unnecessary - - name: Adding Known Hosts - run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - - name: Start new screen session - uses: https://github.com/appleboy/ssh-action@master - with: - host: ${{ env.DEPLOY_HOST }} - username: ${{ env.DEPLOY_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - PATH="$HOME/.local/bin:$PATH" - cd fgo-ta_com - screen -S fgo-ta_com-public -dm serve public/ -p ${{ secrets.DEPLOY_TARGET_PORT }} diff --git a/.forgejo/workflows/linting.yml b/.forgejo/workflows/linting.yml new file mode 100644 index 0000000..b759eae --- /dev/null +++ b/.forgejo/workflows/linting.yml @@ -0,0 +1,16 @@ +on: + push: + branches: + - "**" + +jobs: + checking: + runs-on: docker + container: node:lts + steps: + - name: Checkout source code + uses: https://code.forgejo.org/actions/checkout@v3 + - name: Install packages + run: npm install + - name: Run astro check (linting + static analysis) + run: npm run astro check diff --git a/.forgejo/workflows/redeploy.yml b/.forgejo/workflows/redeploy.yml deleted file mode 100644 index 5d6ecaf..0000000 --- a/.forgejo/workflows/redeploy.yml +++ /dev/null @@ -1,31 +0,0 @@ -on: workflow_dispatch - -jobs: - redeploy-site: - runs-on: docker - env: - DEPLOY_USER: ${{ secrets.DEPLOY_USER }} - DEPLOY_HOST: ${{ secrets.DEPLOY_HOST }} - steps: - - name: Install and update ssh + rsync - run: | - which rsync || ( apt update -y && apt install rsync -y) - which ssh-agent || ( apt update -y && apt install openssh-client -y) - - name: Install SSH Key - uses: https://github.com/shimataro/ssh-key-action@v2 - with: - key: ${{ secrets.SSH_PRIVATE_KEY }} - known_hosts: unnecessary - - name: Adding Known Hosts - run: ssh-keyscan -H ${{ secrets.DEPLOY_HOST }} >> ~/.ssh/known_hosts - - name: Restart screen session - uses: https://github.com/appleboy/ssh-action@master - with: - host: ${{ env.DEPLOY_HOST }} - username: ${{ env.DEPLOY_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - screen -X -S fgo-ta_com-public kill - PATH="$HOME/.local/bin:$PATH" - cd fgo-ta_com - screen -S fgo-ta_com-public -dm serve public/ -p ${{ secrets.DEPLOY_TARGET_PORT }} diff --git a/.vscode/settings.json b/.vscode/settings.json index ff5ea15..3b2788d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,8 @@ "**/CVS": true, "**/.DS_Store": true, "**/Thumbs.db": true, - "**/__pycache__": true + "**/__pycache__": true, + "**/node_modules": false }, "hide-files.files": [] } \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..eaafd14 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM node:lts AS build +WORKDIR /app +COPY . . +RUN npm i +RUN npm run build + +FROM node:lts AS runtime +RUN npm install --global "@warren-bank/serve" + +COPY --from=build /app/dist /public +COPY --from=build /app/serve.json /public/serve.json + +ENV PORT 5000 +EXPOSE 5000 + +CMD [ "serve" "public/" "-p" "5000" ] diff --git a/public/favicon.svg b/public/favicon.svg deleted file mode 100644 index f157bd1..0000000 --- a/public/favicon.svg +++ /dev/null @@ -1,9 +0,0 @@ - - - -