From 80255f98de8e98c9a8c5abf361fd4664c8a03ee6 Mon Sep 17 00:00:00 2001 From: Kilu Date: Sun, 30 Jun 2024 15:45:01 +0800 Subject: [PATCH] fix: deploy --- .github/workflows/deploy_test_web.yaml | 75 ---------------------- frontend/appflowy_web_app/Dockerfile | 7 +- frontend/appflowy_web_app/supervisord.conf | 9 +++ 3 files changed, 14 insertions(+), 77 deletions(-) delete mode 100644 .github/workflows/deploy_test_web.yaml create mode 100644 frontend/appflowy_web_app/supervisord.conf diff --git a/.github/workflows/deploy_test_web.yaml b/.github/workflows/deploy_test_web.yaml deleted file mode 100644 index dc9b30044c..0000000000 --- a/.github/workflows/deploy_test_web.yaml +++ /dev/null @@ -1,75 +0,0 @@ -name: Deploy Web (Test) - -on: - push: - branches: - - build/old-test -env: - NODE_VERSION: "18.16.0" - PNPM_VERSION: "8.5.0" - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} - cancel-in-progress: true - -jobs: - deploy: - runs-on: ubuntu-latest - env: - SSH_PRIVATE_KEY: ${{ secrets.WEB_TEST_SSH_PRIVATE_KEY }} - REMOTE_HOST: ${{ secrets.WEB_TEST_REMOTE_HOST }} - REMOTE_USER: ${{ secrets.WEB_TEST_REMOTE_USER }} - SSL_CERTIFICATE: ${{ secrets.WEB_TEST_SSL_CERTIFICATE }} - SSL_CERTIFICATE_KEY: ${{ secrets.WEB_TEST_SSL_CERTIFICATE_KEY }} - ENV_FILE: test.env - steps: - - uses: actions/checkout@v4 - - name: setup node - uses: actions/setup-node@v3 - with: - node-version: ${{ env.NODE_VERSION }} - - name: setup pnpm - uses: pnpm/action-setup@v2 - with: - version: ${{ env.PNPM_VERSION }} - - name: Node_modules cache - uses: actions/cache@v2 - with: - path: frontend/appflowy_web_app/node_modules - key: node-modules-${{ runner.os }} - - name: install frontend dependencies - working-directory: frontend/appflowy_web_app - run: | - pnpm install - - name: copy env file - working-directory: frontend/appflowy_web_app - run: | - cp ${{ env.ENV_FILE }} .env - - name: test and lint - working-directory: frontend/appflowy_web_app - run: | - pnpm run lint - - name: build - working-directory: frontend/appflowy_web_app - run: | - pnpm run build - - name: generate SSL certificate - run: | - echo "${{ env.SSL_CERTIFICATE }}" > nginx-signed.crt - echo "${{ env.SSL_CERTIFICATE_KEY }}" > nginx-signed.key - - name: Deploy to EC2 - uses: easingthemes/ssh-deploy@main - with: - SSH_PRIVATE_KEY: ${{ env.SSH_PRIVATE_KEY }} - ARGS: "-rlgoDzvc -i" - SOURCE: "frontend/appflowy_web_app/dist frontend/appflowy_web_app/server.cjs frontend/appflowy_web_app/start.sh frontend/appflowy_web_app/Dockerfile frontend/appflowy_web_app/nginx.conf frontend/appflowy_web_app/.env nginx-signed.crt nginx-signed.key" - REMOTE_HOST: ${{ env.REMOTE_HOST }} - REMOTE_USER: ${{ env.REMOTE_USER }} - TARGET: /home/${{ env.REMOTE_USER }}/appflowy-web-app - EXCLUDE: "frontend/appflowy_web_app/dist/, frontend/appflowy_web_app/node_modules/" - SCRIPT_AFTER: | - cd appflowy-web-app - docker system prune -f - docker build -t appflowy-web-app . - docker rm -f appflowy-web-app || true - docker run -d -p 30012:80 --env-file .env --name appflowy-web-app appflowy-web-app diff --git a/frontend/appflowy_web_app/Dockerfile b/frontend/appflowy_web_app/Dockerfile index 4e48272662..12908f95c3 100644 --- a/frontend/appflowy_web_app/Dockerfile +++ b/frontend/appflowy_web_app/Dockerfile @@ -3,12 +3,14 @@ FROM oven/bun:latest WORKDIR /app RUN apt-get update && \ - apt-get install -y nginx + apt-get install -y nginx supervisor RUN bun install cheerio pino pino-pretty COPY . . +COPY supervisord.conf /app/supervisord.conf + RUN addgroup --system nginx && \ adduser --system --no-create-home --disabled-login --ingroup nginx nginx @@ -22,8 +24,9 @@ COPY nginx.conf /etc/nginx/nginx.conf COPY start.sh /app/start.sh RUN chmod +x /app/start.sh +RUN chmod +x /app/supervisord.conf EXPOSE 80 -CMD ["/app/start.sh"] +CMD ["supervisord", "-c", "/app/supervisord.conf"] \ No newline at end of file diff --git a/frontend/appflowy_web_app/supervisord.conf b/frontend/appflowy_web_app/supervisord.conf new file mode 100644 index 0000000000..943c9dfc4d --- /dev/null +++ b/frontend/appflowy_web_app/supervisord.conf @@ -0,0 +1,9 @@ +[supervisord] +nodaemon=true + +[program:start] +command=sh /app/start.sh +autostart=true +autorestart=true +stderr_logfile=/var/log/start.err.log +stdout_logfile=/var/log/start.out.log