Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding folder .gihub/workflows with file ci.yml #6

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
d42bcb0
Adding folder .gihub/workflows with file ci.yml
FreCalvo Nov 27, 2024
8d52ae6
Update todo.js
FreCalvo Nov 27, 2024
5fa9e9f
Adding changes in the backend CI
OscarAstua29 Nov 27, 2024
4260333
Adding changes in the backend CI
OscarAstua29 Nov 27, 2024
6df8d9b
adding a comment in backend/dockerfile to test the backend-ci.yml
OscarAstua29 Nov 27, 2024
6e1b213
changing the version of buildx-actions in backend-ci.yml
OscarAstua29 Nov 27, 2024
a376753
deleting the last comment in backend/dockerfile to test the backend-c…
OscarAstua29 Nov 27, 2024
1def049
adding a dot at the end of the step build and tag Docker Image
OscarAstua29 Nov 27, 2024
fb1380f
adding comment in backend/dockerfile to test the backend-ci.yml
OscarAstua29 Nov 27, 2024
8281764
Update backend-CI.yml to add ESlint
FreCalvo Nov 29, 2024
1576569
Update node version in backend-CI.yml
FreCalvo Nov 29, 2024
b79a8ac
Update server.js of backend to test backend-CI.yml
FreCalvo Nov 29, 2024
6d92426
Update node version in backend-CI.yml to 18.8.0. Update eslint.config…
FreCalvo Nov 29, 2024
93ce8e9
Update files to allow proper execution of ESlint
FreCalvo Nov 29, 2024
a3e61d8
Update package.json within backend
FreCalvo Nov 29, 2024
6c1788b
Update package.lock.json within backend
FreCalvo Nov 29, 2024
1e8a3f6
Update files
FreCalvo Nov 29, 2024
80c8433
Update .github/workflows/backend-CI.yml to add npm install before exe…
FreCalvo Nov 29, 2024
5a2b2d7
Update files
FreCalvo Nov 29, 2024
f8d8a67
Rename eslint.config.cjs as eslint.config.mjs
FreCalvo Nov 29, 2024
cf473fd
Update backend/package.json to add module type
FreCalvo Nov 29, 2024
bb126ca
Update eslint.config.mjs
FreCalvo Nov 29, 2024
befaf78
Update backend/server.js to test CI
FreCalvo Nov 29, 2024
0fe816f
rename eslint.config.mjs to eslint.config.cjs with respective contect…
FreCalvo Nov 29, 2024
52cef0e
Update files
FreCalvo Nov 29, 2024
138fe5c
Update backend-CI.yml to remove ESLint actions
FreCalvo Nov 29, 2024
197c3d8
Update files to remove ESlint actions
FreCalvo Nov 29, 2024
9305418
Update backend-CI.yml
FreCalvo Nov 29, 2024
3815159
Update backend/Docker file
FreCalvo Nov 29, 2024
b251d90
Remove space in backend/Dockerfile to test CI
FreCalvo Nov 29, 2024
863e45f
Update backend/package.json
FreCalvo Nov 29, 2024
bb70821
Update .github/workflows/FE_BE_CI.yml to add frontend steps
FreCalvo Nov 29, 2024
de97011
Minor updated in Docker files of BE and FE to test .yml file
FreCalvo Nov 29, 2024
01b7085
Rename .yml file for CI
FreCalvo Nov 29, 2024
86d422f
adding deploy-instance-app.yml and the respective config.sh
OscarAstua29 Dec 20, 2024
85b8ec0
adding terraform file with cluster configuration
OscarAstua29 Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/backend-frontend-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Build and push docker images

on:
push:
paths:
- 'backend/**'
- 'frontend/**'
branches:
- develop
- master
pull_request:
paths:
- 'backend/**'
- 'frontend/**'
- develop
- master

jobs:
build-and-push:
runs-on: ubuntu-latest
if: github.ref_name == 'develop' || github.ref_name == 'master'

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

# Extracción de versiones
- name: Extract backend version
id: backend_version
run: echo "BACKEND_VERSION=$(jq -r .version < backend/package.json)" >> $GITHUB_ENV

- name: Extract frontend version
id: frontend_version
run: echo "FRONTEND_VERSION=$(jq -r .version < frontend/package.json)" >> $GITHUB_ENV

# Build y Push Backend
- name: Build Backend Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/backend:v${{ env.BACKEND_VERSION }} backend/

- name: Push Backend Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/backend:v${{ env.BACKEND_VERSION }}

# Build y Push Frontend
- name: Build Frontend Docker image
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/frontend:v${{ env.FRONTEND_VERSION }} frontend/

- name: Push Frontend Docker image
run: |
docker push ${{ secrets.DOCKER_USERNAME }}/frontend:v${{ env.FRONTEND_VERSION }}

# Pull para confirmar
- name: Pull Backend Docker image
run: |
docker pull ${{ secrets.DOCKER_USERNAME }}/backend:v${{ env.BACKEND_VERSION }}

- name: Pull Frontend Docker image
run: |
docker pull ${{ secrets.DOCKER_USERNAME }}/frontend:v${{ env.FRONTEND_VERSION }}
5 changes: 4 additions & 1 deletion backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ COPY . .

EXPOSE 3001

CMD ["node", "server.js"]
CMD ["node", "server.js", ""]


#delete this line its just for a ci test
2 changes: 1 addition & 1 deletion backend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ RUN npm install
COPY . .

EXPOSE 3000
CMD ["npm", "start"]
CMD ["npm","start"]
39 changes: 39 additions & 0 deletions instance-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

# Actualizar los paquetes del sistema
echo "UPDATING SYSTEM"
sudo yum update -y

# Instalar Docker
echo "DOCKER INSTALATION"
sudo yum install -y docker

# Verificar la versión de Docker
echo "DOCKER VERSION"
docker --version

# Iniciar el servicio de Docker
echo "DOCKER START"
sudo service docker start

# Añadir el usuario 'ec2-user' al grupo 'docker' para usar Docker sin sudo
echo "ADDING EC2 TO DOCKER GROUP"
sudo usermod -a -G docker ec2-user

# Instalar Docker Compose
echo "DOCKER-COMPOSE INSTALATION"
sudo curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

# Hacer ejecutable el binario de Docker Compose
echo "CHANGING DOCKER PERMISSIONS"
sudo chmod +x /usr/local/bin/docker-compose

# Verificar la versión de Docker Compose
echo "DOCKER-COMPOSE VERSION"
sudo docker-compose version

# Ejecutar Docker Compose en modo 'detached' (en segundo plano)
echo "INITIALIZING DOCKER COMPOSE"
sudo docker-compose up -d

echo "SCRIPT ENDS"
55 changes: 55 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "~> 5.0"
}
}
required_version = ">= 1.3.0"
}

provider "google" {
project = "onyx-dragon-445317-g5" # Reemplaza con tu ID de proyecto
region = "us-central1"
zone = "us-central1-a"
}

resource "google_container_cluster" "primary" {
name = "cloud-station-cluster"
location = "us-central1-a"

remove_default_node_pool = true # Elimina el pool por defecto
initial_node_count = 1 # Requerido, pero ignorado al quitar el default pool

network = "default" # Usa la red por defecto
}

resource "google_container_node_pool" "nodes" {
name = "mi-nodo-pool"
location = "us-central1-a"
cluster = google_container_cluster.primary.name
node_count = 1

node_config {
preemptible = true
machine_type = "e2-micro"
disk_size_gb = 10
disk_type = "pd-standard" # Cambia a disco estándar (evita SSD)

oauth_scopes = [
"https://www.googleapis.com/auth/cloud-platform"
]
}
}

output "kubernetes_cluster_name" {
value = google_container_cluster.primary.name
}

output "endpoint" {
value = google_container_cluster.primary.endpoint
}

output "ca_certificate" {
value = google_container_cluster.primary.master_auth[0].cluster_ca_certificate
}