diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml
new file mode 100644
index 0000000..597d41c
--- /dev/null
+++ b/.github/workflows/python-app.yml
@@ -0,0 +1,42 @@
+name: Python + Docker
+
+on:
+ push:
+ branches: [ "main" ]
+ pull_request:
+ branches: [ "main" ]
+
+jobs:
+ test:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Set up Python 3.10
+ uses: actions/setup-python@v4
+ with:
+ python-version: "3.10"
+
+ - name: Install dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install -r requirements.txt
+
+ - name: Run tests
+ run: pytest
+
+ docker:
+ runs-on: ubuntu-latest
+ needs: test # só roda o Docker se os testes passarem
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Build Docker image
+ run: docker build -t testandodocker .
+
+ - name: Run container
+ run: docker run -d -p 8000:80 --name test_container testandodocker
+
+ - name: Check container logs
+ run: docker logs test_container
diff --git a/.idea/devops-puc.iml b/.idea/devops-puc.iml
index d6ebd48..10ba783 100644
--- a/.idea/devops-puc.iml
+++ b/.idea/devops-puc.iml
@@ -3,7 +3,7 @@
-
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 6f29fee..8be8c38 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,7 @@
-
-
+
+
+
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..c94b5e4
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,12 @@
+FROM python:3
+
+WORKDIR /usr/src/app
+
+COPY requirements.txt ./
+RUN pip install --no-cache-dir -r requirements.txt
+
+COPY . .
+
+EXPOSE 80
+
+CMD [ "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "80" ]
diff --git a/main.py b/main.py
new file mode 100644
index 0000000..3748535
--- /dev/null
+++ b/main.py
@@ -0,0 +1,7 @@
+from fastapi import FastAPI
+
+app = FastAPI()
+
+@app.get("/")
+def home():
+ return {"mensagem": "API funcionando no Docker!"}
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..57a493a
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1,3 @@
+fastapi==0.111.1
+uvicorn[standard]
+
diff --git a/tests/test_01.py b/tests/test_01.py
new file mode 100644
index 0000000..30fe67b
--- /dev/null
+++ b/tests/test_01.py
@@ -0,0 +1,13 @@
+"""Testes automatizados para o módulo main."""
+
+from main import read_root
+
+
+def test_passando():
+ """Teste que sempre passa."""
+ assert True
+
+def test_read_root():
+ """Teste da função read_root()."""
+ response = read_root()
+ assert response == {"hello": "world"}