Skip to content

Commit e6f5b4c

Browse files
authored
Merge pull request #6 from YosefKahlon/week7
Week7
2 parents 00de3b2 + 5b983e6 commit e6f5b4c

1,866 files changed

Lines changed: 729888 additions & 14 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
name: CI Workflow
22

33
on:
4-
push:
5-
branches:
6-
- week5
7-
- main
8-
pull_request:
9-
branches:
10-
- main
4+
# push:
5+
# branches:
6+
# - week5
7+
# - main
8+
# pull_request:
9+
# branches:
10+
# - main
1111
workflow_dispatch:
1212

1313
env:

.github/workflows/ci_week7.yml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: End-to-End Tests
2+
3+
on:
4+
push:
5+
branches: [week7]
6+
workflow_dispatch:
7+
8+
9+
jobs:
10+
e2e:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Build Docker containers
18+
run: docker compose build
19+
working-directory: week7
20+
21+
- name: Start containers
22+
run: docker compose up -d
23+
working-directory: week7
24+
25+
- name: Wait for DB healthcheck
26+
run: |
27+
timeout=30
28+
for i in $(seq 1 $timeout); do
29+
status=$(docker inspect --format='{{.State.Health.Status}}' $(docker compose ps -q db))
30+
echo "DB health: $status"
31+
[ "$status" = "healthy" ] && break
32+
sleep 1
33+
done
34+
working-directory: week7
35+
36+
- name: Wait for backend to become healthy
37+
run: |
38+
timeout=30
39+
for i in $(seq 1 $timeout); do
40+
status=$(docker inspect --format='{{.State.Health.Status}}' $(docker compose ps -q backend))
41+
echo "Backend health: $status"
42+
[ "$status" = "healthy" ] && break
43+
sleep 1
44+
done
45+
working-directory: week7
46+
47+
- name: Test API endpoints
48+
run: |
49+
curl --fail http://localhost:3000/health
50+
curl --fail http://localhost:3000/api/users
51+
working-directory: week7
52+
53+
- name: Capture logs on failure
54+
if: failure()
55+
run: docker compose logs > full_logs.txt
56+
working-directory: week7
57+
58+
- name: Upload logs
59+
if: always()
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: docker-compose-logs
63+
path: week7/full_logs.txt
64+
65+
- name: Shut down containers
66+
if: always()
67+
run: docker compose down --volumes
68+
working-directory: week7
69+
70+
71+
deploy:
72+
needs: e2e
73+
runs-on: ubuntu-latest
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Set up SSH key
80+
run: |
81+
mkdir -p ~/.ssh
82+
echo "${{ secrets.AZURE_VM_KEY }}" > ~/.ssh/myDockerVM_key.pem
83+
chmod 600 ~/.ssh/myDockerVM_key.pem
84+
85+
- name: Copy files to Azure VM (excluding frontend)
86+
run: |
87+
rsync -av --exclude=frontend -e "ssh -i ~/.ssh/myDockerVM_key.pem -o StrictHostKeyChecking=no" week7/ ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }}:~/week7/
88+
89+
- name: Deploy with Docker Compose on Azure VM
90+
run: |
91+
ssh -i ~/.ssh/myDockerVM_key.pem -o StrictHostKeyChecking=no ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }} '
92+
cd ~/week7 && docker-compose up --build -d
93+
'
94+
95+
- name: Check service health on Azure VM
96+
run: |
97+
ssh -i ~/.ssh/myDockerVM_key.pem -o StrictHostKeyChecking=no ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }} '
98+
curl -f http://localhost:3000/health
99+
'
100+
101+
- name: Shut down containers on Azure VM
102+
if: always()
103+
run: |
104+
ssh -i ~/.ssh/myDockerVM_key.pem -o StrictHostKeyChecking=no ${{ secrets.AZURE_VM_USER }}@${{ secrets.AZURE_VM_HOST }} '
105+
cd ~/week7 && docker-compose down --volumes
106+
'

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1+
# DevOps & Linux Learning Repository
2+
3+
This repository contains my hands-on notes, scripts, and project work for learning DevOps, Linux, Docker, CI/CD, and cloud deployment.
14

2-
# Part 1
35
* [Linux basic commands](./week1/Intro%20to%20DevOps%20and%20Linux.md)
46

5-
# Part 2
7+
68
* [Intro to Shell scripting](./week2_practice/Shell%20scripting.md)
79

810
* [Advanced Log Report Automation](./week2_Summary/Advanced%20Log%20Report%20Automation.md)
911

10-
# Part 3
1112
* [Networking & SSH](./week3_practice/Networking%20&%20SSH.md)
1213

13-
# Part 4
14+
1415
* [Advanced Git & GitHub](./week4/github_practice.md)
1516

16-
# Part 5
17+
1718
* [CI/CD with GitHub Action](./week5/CICD_with_GitHub_Actions.md)
1819

20+
* [Docker-Containers](./week6/Docker-Containers.md)
21+
1922

20-
# Prat 6
21-
* [Docker-Containers](./week6/Docker-Containers.md)
23+
* [Docker Compose & Azure + VM ](./week7/Docker%20Compose%20&%20Azure+VM.md)

node_modules/.package-lock.json

Lines changed: 34 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/cors/LICENSE

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/cors/README.md

Lines changed: 75 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/cors/index.d.ts

Lines changed: 56 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@types/cors/package.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)