From 31ec7ad77f3b964397134d95321bc92fffaf2168 Mon Sep 17 00:00:00 2001 From: AruSeito Date: Wed, 3 Jan 2024 21:36:54 +0800 Subject: [PATCH] ci: change host --- .github/workflows/deploy.yml | 62 +++++++++++++++++++++------- .idea/.gitignore | 5 --- .idea/codeStyles/Project.xml | 59 -------------------------- .idea/codeStyles/codeStyleConfig.xml | 5 --- .idea/illa-website.iml | 12 ------ .idea/modules.xml | 8 ---- .idea/vcs.xml | 6 --- Dockerfile | 13 ++++++ docusaurus.config.ts | 9 +--- illa-website-frontend.conf | 19 +++++++++ nginx.conf | 38 +++++++++++++++++ static/robots.txt | 4 +- 12 files changed, 120 insertions(+), 120 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/codeStyles/Project.xml delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/illa-website.iml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml create mode 100644 Dockerfile create mode 100644 illa-website-frontend.conf create mode 100644 nginx.conf diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5195b56755..a267b7c19e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -4,19 +4,27 @@ on: push: branches: - main - # Review gh actions docs if you want to further define triggers, paths, etc - # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#on + - beta + - develop permissions: contents: write env: + DO_CLUSTER: ${{ secrets.DO_CLUSTER }} + DOCKER_LOGIN: ${{ secrets.DOCKER_LOGIN }} + DOCKER_PWD: ${{ secrets.DOCKER_PWD }} CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_BOT_TOKEN }} jobs: deploy: name: Deploy to GitHub Pages runs-on: ubuntu-latest + environment: + name: + ${{ (github.ref == 'refs/heads/main') && 'production' || (github.ref == + 'refs/heads/develop') && 'test' || (github.ref == 'refs/heads/beta') && + 'beta' }} steps: - uses: actions/checkout@v3 @@ -49,18 +57,40 @@ jobs: - name: Build website run: pnpm build - # Popular action to deploy to GitHub Pages: - # Docs: https://github.com/peaceiris/actions-gh-pages#%EF%B8%8F-docusaurus - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 + - name: Install doctl + uses: digitalocean/action-doctl@v2 with: - github_token: ${{ secrets.GITHUB_TOKEN }} - # Build output to publish to the `gh-pages` branch: - publish_dir: ./build - # The following lines assign commit authorship to the official - # GH-Actions bot for deploys to `gh-pages` branch: - # https://github.com/actions/checkout/issues/13#issuecomment-724415212 - # The GH actions bot is used by default if you didn't specify the two fields. - # You can swap them out with your own user credentials. - user_name: github-actions[bot] - user_email: 41898282+github-actions[bot]@users.noreply.github.com + token: ${{ secrets.DO_TOKEN }} + + - name: Install kubectl + run: | + sudo snap install kubectl --classic + + - name: Setup kubectl + run: | + doctl kubernetes cluster kubeconfig save $DO_CLUSTER + kubectl version + + - name: Build Docker + run: | + docker build --cache-from=illa-website-frontend -f Dockerfile -t illa-website-frontend . + + + - name: Push application Docker image + run: | + docker login -u $DOCKER_LOGIN -p $DOCKER_PWD + docker tag illa-website-frontend "illasoft/illa-website-frontend:$GITHUB_REF_NAME" + docker push "illasoft/illa-website-frontend:$GITHUB_REF_NAME" + + + - uses: actions/checkout@v4 + with: + repository: illacloud/k8s-application-do + token: ${{ secrets.ILLA_BOT_TOKEN }} + path: k8s-application-do + + - name: Deploy to Kubernetes + run: | + cd k8s-application-do/namespace-$ILLA_APP_ENV + kubectl apply -f ./illa-website-frontend/ -n $ILLA_APP_ENV + kubectl rollout restart deployment illa-website-frontend -n $ILLA_APP_ENV diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 10b731c518..0000000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -# 默认忽略的文件 -/shelf/ -/workspace.xml -# 基于编辑器的 HTTP 客户端请求 -/httpRequests/ diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml deleted file mode 100644 index 5491b1bd92..0000000000 --- a/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index 79ee123c2b..0000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/illa-website.iml b/.idea/illa-website.iml deleted file mode 100644 index 24643cc374..0000000000 --- a/.idea/illa-website.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 53babdf48d..0000000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1ddfbb..0000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..708e803849 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM nginx:stable-alpine as runner + +## copy frontend +COPY nginx.conf /etc/nginx/nginx.conf +COPY illa-website-frontend.conf /etc/nginx/conf.d/illa-website-frontend.conf +COPY ./build /opt/illa/illa-website-frontend +RUN rm /etc/nginx/conf.d/default.conf + +# test nginx +RUN nginx -t + +# run +EXPOSE 3000 \ No newline at end of file diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 82ee122908..1cda81ddf3 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -9,17 +9,12 @@ const config: Config = { favicon: "img/public/favicon.ico", // Set the production url of your site here - url: "https://illacloud.github.io", + url: "https://illa.cloud", // Set the // pathname under which your site is served // For GitHub pages deployment, it is often '//' - baseUrl: "/illa-website/", + baseUrl: "/", staticDirectories: ["public", "static"], - // GitHub pages deployment config. - // If you aren't using GitHub pages, you don't need these. - organizationName: "illacloud", // Usually your GitHub org/user name. - projectName: "illa-website", // Usually your repo name. - onBrokenLinks: "warn", onBrokenMarkdownLinks: "warn", diff --git a/illa-website-frontend.conf b/illa-website-frontend.conf new file mode 100644 index 0000000000..ea48c24db4 --- /dev/null +++ b/illa-website-frontend.conf @@ -0,0 +1,19 @@ +server { + listen 80; + server_name localhost; + access_log /dev/stdout; + error_log /dev/stderr; + root /opt/illa/illa-website-frontend/; + index index.html; + gzip on; + + sub_filter_once off; + location / { + try_files $uri $uri/ /index.html; + expires -1; + } + + location /assets { + expires 1y; + } +} \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000000..b58f40d879 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,38 @@ +user nginx; +worker_processes 1; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + +events { + worker_connections 1024; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '"$time_local" client=$remote_addr ' + 'method=$request_method request="$request" ' + 'request_length=$request_length ' + 'status=$status bytes_sent=$bytes_sent ' + 'body_bytes_sent=$body_bytes_sent ' + 'referer=$http_referer ' + 'http_x_forwarded_for=$http_x_forwarded_for ' + 'user_agent="$http_user_agent" ' + 'upstream_addr=$upstream_addr ' + 'upstream_status=$upstream_status ' + 'request_time=$request_time ' + 'upstream_response_time=$upstream_response_time ' + 'upstream_connect_time=$upstream_connect_time ' + 'upstream_header_time=$upstream_header_time'; + + access_log /var/log/nginx/access.log main; + + sendfile on; + + keepalive_timeout 65; + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/static/robots.txt b/static/robots.txt index 011f502889..fba1d1a405 100644 --- a/static/robots.txt +++ b/static/robots.txt @@ -1,6 +1,6 @@ User-agent: * -Host: https://illacloud.github.io/illa-website/ -Sitemap: https://illacloud.github.io/illa-website/sitemap.xml +Host: https://illa.cloud +Sitemap: https://illa.cloud/sitemap.xml Disallow: https://cloud.illacloud.com/* Disallow: https://builder.illacloud.com/* Disallow: https://status.illacloud.com/