diff --git a/.gitea/workflows/deploy-ssh.yaml b/.gitea/workflows/deploy-ssh.yaml deleted file mode 100644 index 61b491d..0000000 --- a/.gitea/workflows/deploy-ssh.yaml +++ /dev/null @@ -1,38 +0,0 @@ -name: Deploy Angular via SSH -on: [push] - -jobs: - build-and-deploy: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Setup Node 16 - uses: actions/setup-node@v3 - with: - node-version: 16 - - - name: Install and Build - run: | - npm install --legacy-peer-deps - npm run build -- --prod - - - name: Transferir arquivos via SCP - uses: https://github.com/appleboy/scp-action@master - with: - host: ${{ secrets.REMOTE_HOST }} - username: ${{ secrets.REMOTE_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - source: "dist/" - target: "/var/www/html/vendaweb-frontend" - strip_components: 1 - - - name: Reiniciar Nginx Remoto - uses: https://github.com/appleboy/ssh-action@master - with: - host: ${{ secrets.REMOTE_HOST }} - username: ${{ secrets.REMOTE_USER }} - key: ${{ secrets.SSH_PRIVATE_KEY }} - script: | - sudo systemctl reload nginx \ No newline at end of file diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..10f03c1 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -0,0 +1,14 @@ +on: [push] +jobs: + build-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Login Harbor + run: echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 172.35.0.216 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin + - name: Build/Push + run: | + docker build -t 172.35.0.216/library/vendaweb-portal:latest . + docker push 172.35.0.216/library/vendaweb-portal:latest + - name: Webhook Portainer + run: curl -X POST "${{ secrets.PORTAINER_WEBHOOK_FRONT }}" \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d226448 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM node:16-bullseye-slim AS builder +WORKDIR /app +COPY package*.json ./ +RUN npm install --legacy-peer-deps +COPY . . +RUN npm run build -- --prod + +FROM nginx:alpine +RUN apk add --no-cache gettext # Para o envsubst funcionar +COPY --from=builder /app/dist/seu-projeto /usr/share/nginx/html + +CMD ["/bin/sh", "-c", "envsubst < /usr/share/nginx/html/assets/env.template.js > /usr/share/nginx/html/assets/env.js && exec nginx -g 'daemon off;'"] \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..23e97c1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,23 @@ +version: '3.8' + +services: + frontend: + image: 172.35.0.216/library/vendaweb-portal:latest + networks: + - simplifique-network + environment: + - API_URL=${API_URL} + - URL_PIX=${URL_PIX} + - FIREBASE_API_KEY=${FIREBASE_API_KEY} + deploy: + replicas: 4 + update_config: + parallelism: 1 + order: start-first + restart_policy: + condition: on-failure + +networks: + + simplifique-network: + external: true \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..d8bd44f --- /dev/null +++ b/nginx.conf @@ -0,0 +1,14 @@ +upstream web_servers { + # Nome da Stack + server angular:80; +} + +server { + listen 80; + location / { + proxy_pass http://web_servers; + } + location /api/ { + proxy_pass http://api_servers/; + } +} \ No newline at end of file diff --git a/src/assets/env.template.js b/src/assets/env.template.js new file mode 100644 index 0000000..976b089 --- /dev/null +++ b/src/assets/env.template.js @@ -0,0 +1,5 @@ +(function(window) { + window["env"] = window["env"] || {}; + window["env"]["apiUrl"] = "${API_URL}"; + window["env"]["urlPix"] = "${URL_PIX}"; +})(this); \ No newline at end of file diff --git a/src/index.html b/src/index.html index f62c4d9..1fbab3c 100644 --- a/src/index.html +++ b/src/index.html @@ -37,6 +37,7 @@ + Plataforma Smart