Este repositório contém um pipeline de Continuous Delivery que integra o uso de Terraform, Docker e Ansible para gerenciar a infraestrutura na Magalu Cloud, construir e implantar imagens Docker, e configurar servidores remotamente.
O pipeline é composto por três principais blocos de trabalho definidos em GitHub Actions:
- Terraform Infrastructure Deployment
- Docker Image Build and Push
- Ansible Server Configuration and Deployment
Este job é acionado sempre que houver um push nos arquivos .tf no repositório:
on:
push:
paths:
- "**/*.tf"Etapas do Job
- Setup Terraform: Configura o ambiente Terraform.
- Checkout Repo: Clona o repositório para acessar o código.
- Terraform Init: Inicializa o diretório Terraform..
- Terraform Validate: Valida a configuração do Terraform.
- Terraform Apply: Aplica as mudanças no Terraform.
-
GITHUB_TOKEN: Token de autenticação para GitHub. -
TF_VAR_mgc_api_key: API Key para Magalu Cloud. -
TF_VAR_mgc_region: Região da Magalu Cloud.
Evento de Gatilho
Este job é acionado em push para a branch main:
on:
push:
branches:
- main-
Setup Docker Buildx: Configura o ambiente de build Docker.
-
Docker Login: Autentica no Docker Hub.
-
Build and Push Docker Images: Constrói e publica a imagem Docker no Docker Hub.
USERNAME_DOCKER_HUB: Nome de usuário do Docker Hub.
PASSWORD_DOCKER_HUB: Senha (api-key) do Docker Hub.
Dependência
Este job depende da conclusão do job Docker.
-
Checkout Repo: Clona o repositório.
-
Setup SSH Key: Configura a chave SSH para acesso aos servidores.
-
Run Ansible Playbook: Executa o playbook Ansible para configurar o servidor.
-
SSH_PRIVATE_KEY: Chave privada SSH para acessar o servidor. -
SSH_HOST: Endereço do servidor remoto.
O playbook Ansible realiza as seguintes tarefas:
Atualiza o cache de pacotes e instala dependências para Docker.
Adiciona a chave GPG e repositório do Docker.
Instala e inicia o serviço Docker.
Atualiza a imagem Docker e reinicia o contêiner com a nova imagem.
Certifique-se de que todas as variáveis de ambiente e segredos estejam devidamente configurados antes de executar o pipeline. O pipeline está configurado para aplicar automaticamente mudanças de infraestrutura e atualizações de contêineres; revise cuidadosamente todos os scripts e configurações antes de permitir execuções automáticas em ambientes de produção.
About | Features | Technologies | Requirements | Starting | License | Author
Simple To Do application built with Node.js and Express.js that lets you add tasks on a single page, store new and finished tasks in different arrays. Containerized with Docker and tested with NPM through GitHub Actions pipeline.
✔️ Add tasks
✔️ Store tasks
✔️ Delete tasks
The following tools were used in this project:
EJS simply stands for Embedded Javascript. It is a simple templating language/engine that lets its user generate HTML with plain javascript. EJS is mostly useful whenever you have to output HTML with a lot of javascript. EJS is a simple templating language that lets you generate HTML markup with plain JavaScript. No religiousness about how to organize things. No reinvention of iteration and control-flow.
Body-Parser is the Node. js body parsing middleware. It is responsible for parsing the incoming request bodies in a middleware before you handle it. This extracts the entire body portion of an incoming request stream and exposes it on req.body
Before starting 🏁, you need to have Git and Node installed.
# Clone this project
git clone https://github.com/devenes/node-js-dummy-test
# Access
cd node-js-dummy-test
# install all needed dependencies
npm install
# Start the app in the browser
npm start
# The server will initialize in the <http://localhost:8080>Run npm test to run the tests
Use the following commands in your Dockerfile to build a Docker image:
FROM node:16-alpine
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
EXPOSE 8080
CMD ["npm", "start"]This project is under license from Apache 2.0. For more details, see the LICENSE file.
Made with ❤️ by devenes


