-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ade08f4
commit e1c88cc
Showing
7 changed files
with
807 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,52 @@ | ||
|
||
name: CI-CD | ||
|
||
on: | ||
workflow_dispatch: | ||
push: | ||
env: | ||
docker_image: fabricioveronez/nodejs-web | ||
|
||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Obtendo o código | ||
uses: actions/checkout@v4 | ||
- name: Docker Login | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{secrets.DOCKERHUB_USER}} | ||
password: ${{secrets.DOCKERHUB_PWD}} | ||
|
||
- name: Construção da imagem Docker worker | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: ./src | ||
file: ./src/Dockerfile | ||
push: true | ||
tags: | | ||
"${{ env.docker_image }}:${{github.run_number}}" | ||
"${{ env.docker_image }}:latest" | ||
CD: | ||
runs-on: ubuntu-latest | ||
needs: [CI] | ||
|
||
steps: | ||
- name: Obtendo o código | ||
uses: actions/checkout@v3 | ||
|
||
- name: Configuração do Kubeconfig | ||
uses: azure/k8s-set-context@v4 | ||
with: | ||
method: kubeconfig | ||
kubeconfig: ${{ secrets.K8S_CONFIG }} | ||
|
||
- name: Deploy no cluster Kubernetes | ||
uses: Azure/k8s-deploy@v5 | ||
with: | ||
manifests: | | ||
./k8s/deployment.yaml | ||
images: | | ||
"${{ env.docker_image }}:${{github.run_number}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: web | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: web | ||
template: | ||
metadata: | ||
labels: | ||
app: web | ||
spec: | ||
containers: | ||
- name: web | ||
image: fabricioveronez/nodejs-web | ||
ports: | ||
- containerPort: 8080 | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: web | ||
spec: | ||
selector: | ||
app: web | ||
ports: | ||
- port: 80 | ||
targetPort: 8080 | ||
type: LoadBalancer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM node:20.12.0 | ||
WORKDIR /app | ||
COPY package*.json ./ | ||
RUN npm install | ||
COPY . . | ||
EXPOSE 8080 | ||
CMD ["node", "index.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const express = require('express'); | ||
const app = express(); | ||
|
||
app.route('/').get((req, res) => { | ||
res.send('<h1>Aplicacao exemplo</h1>'); | ||
}); | ||
|
||
app.listen(8080, () => { | ||
console.log('Aplicacao rodando na porta 3000'); | ||
}); |
Oops, something went wrong.