From ad735969678e835e0d525222ac36c61e1a5d396e Mon Sep 17 00:00:00 2001 From: schmelczerandras Date: Fri, 2 Oct 2020 15:41:21 +0200 Subject: [PATCH] Add firebase --- .github/workflows/main.yaml | 51 ++++++++---------------------- frontend/.firebaserc | 5 +++ frontend/.gitignore | 1 + frontend/Dockerfile | 28 ----------------- frontend/firebase.json | 16 ++++++++++ frontend/nginx-config/nginx.conf | 53 -------------------------------- frontend/package.json | 2 +- 7 files changed, 35 insertions(+), 121 deletions(-) create mode 100644 frontend/.firebaserc delete mode 100644 frontend/Dockerfile create mode 100644 frontend/firebase.json delete mode 100644 frontend/nginx-config/nginx.conf diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b22557a..f82c1b1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,50 +1,23 @@ -name: Deploy everything +name: Deploy site on: push: branches: - main -env: - CONTAINER_REGISTRY: schmelczera - DOMAIN: decla.red - jobs: - build-frontend: + firebase-deploy: runs-on: ubuntu-latest steps: - name: Checkout current branch with lfs - uses: actions/checkout@main - with: - lfs: true - - - name: Setup auth tokens + uses: actions/checkout@master + - name: Build site run: | - docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} - - - name: Build and push frontend - run: | - docker build . -t $CONTAINER_REGISTRY/declared-frontend - docker push $CONTAINER_REGISTRY/declared-frontend + npm install + npm run build working-directory: frontend - - deploy: - runs-on: ubuntu-latest - needs: - - build-frontend - steps: - - name: Checkout current branch with lfs - uses: actions/checkout@main + - name: Deploy html + uses: w9jds/firebase-action@master with: - lfs: true - - - name: Setup auth tokens - run: | - # SSH key - mkdir ~/.ssh - echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_ed25519 - chmod 400 ~/.ssh/id_ed25519 - ssh -o StrictHostKeyChecking=no root@$DOMAIN uptime - - - name: Stack deploy - run: | - DOCKER_HOST=ssh://root@$DOMAIN docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} - DOCKER_HOST=ssh://root@$DOMAIN docker stack deploy declared -c docker-compose.yml --with-registry-auth + args: deploy --only --project decla-red + env: + FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} + PROJECT_PATH: frontend diff --git a/frontend/.firebaserc b/frontend/.firebaserc new file mode 100644 index 0000000..1c74fcc --- /dev/null +++ b/frontend/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "decla-red" + } +} diff --git a/frontend/.gitignore b/frontend/.gitignore index 91a3983..bf0cd0d 100644 --- a/frontend/.gitignore +++ b/frontend/.gitignore @@ -1,3 +1,4 @@ dist node_modules package-lock.json +.firebase diff --git a/frontend/Dockerfile b/frontend/Dockerfile deleted file mode 100644 index d7c92e0..0000000 --- a/frontend/Dockerfile +++ /dev/null @@ -1,28 +0,0 @@ -FROM schmelczera/error-pages as build-error-pages -RUN python build.py 403 404 50x - - -FROM node:latest as build-webpage -WORKDIR /home/node - -COPY src src -COPY static static -COPY package.json custom.d.ts tsconfig.json webpack.config.js ./ - -RUN npm install -RUN npm run build - - -FROM nginx:alpine - -HEALTHCHECK --interval=1m --timeout=10s CMD curl --fail http://localhost/ || exit 1 - -WORKDIR /usr/share/nginx/html - -RUN rm -rf * -COPY --from=build-webpage /home/node/dist . -COPY --from=build-error-pages /home/python/built errors -RUN find . -type f | xargs gzip -k9 &&\ - chmod -R 555 . - -COPY nginx-config /etc/nginx/ diff --git a/frontend/firebase.json b/frontend/firebase.json new file mode 100644 index 0000000..2c33c29 --- /dev/null +++ b/frontend/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "dist", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/frontend/nginx-config/nginx.conf b/frontend/nginx-config/nginx.conf deleted file mode 100644 index a8bfb5a..0000000 --- a/frontend/nginx-config/nginx.conf +++ /dev/null @@ -1,53 +0,0 @@ -user nginx; -worker_processes auto; - -error_log /var/log/nginx/error.log warn; - -pid /var/run/nginx.pid; - -events { - worker_connections 1024; -} - -http { - server_tokens off; - - include /etc/nginx/mime.types; - default_type application/octet-stream; - - access_log off; - - sendfile on; - sendfile_max_chunk 1m; - tcp_nopush on; - - keepalive_timeout 65; - - gzip on; - gzip_static on; - gzip_vary on; - gzip_min_length 10240; - gzip_proxied any; - gzip_disable "MSIE [1-6]\.(?!.*SV1)"; - - server { - listen 80; - server_name localhost; - - root /usr/share/nginx/html; - index index.html; - - location ~* \.(jpg|jpeg|png|ico)$ { - expires 30d; - } - - error_page 403 /403.html; - error_page 404 /404.html; - error_page 500 501 502 503 504 /50x.html; - - location ~ ^/(403|404|50x).html$ { - root /usr/share/nginx/html/errors; - internal; - } - } -} diff --git a/frontend/package.json b/frontend/package.json index 2f2c3f1..804df07 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -32,7 +32,7 @@ "css-loader": "^3.5.2", "cssnano": "^4.1.10", "eslint": "^7.2.0", - "sdf-2d": "^0.1.0-alpha", + "sdf-2d": "^0.3.4", "eslint-config-prettier": "^6.11.0", "eslint-plugin-import": "^2.21.2", "eslint-plugin-prettier": "^3.1.4",