Skip to content

Commit aa9e3c3

Browse files
Feat: add Docker setup and run week_004 tests successfully
1 parent 33dba6b commit aa9e3c3

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

Dockerfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 1. Base Image Selection
2+
# Uses an official, lightweight, and minimal Python image based on Debian.
3+
# The "-slim" variant excludes unnecessary system packages, which drastically
4+
# reduces the final image size and minimizes the security attack surface, making
5+
# it ideal for CI/CD test automation pipelines.
6+
FROM python:3.12-slim
7+
8+
# 2. Working Directory Definition
9+
# Creates and establishes "/app" as the absolute working directory inside the container.
10+
# All subsequent instructions (like COPY, RUN, and CMD) will be executed from this path.
11+
# This prevents cluttering the root directory of the container system.
12+
WORKDIR /app
13+
14+
# 3. Dependencies Pre-copy (Cache Optimization)
15+
# Copies only the requirements file from the host machine to the current directory inside the container.
16+
# By isolating this step before copying the rest of the source code, we take advantage
17+
# of Docker's layer caching mechanism. If requirements.txt hasn't changed, Docker skips
18+
# the heavy installation step (Step 4) during future builds, saving valuable build time.
19+
COPY requirements.txt .
20+
21+
# 4. QA Dependency Installation
22+
# Executes the pip installer to install all specified testing frameworks (such as pytest, requests, jsonschema).
23+
# The "--no-cache-dir" flag is a production best practice: it forces pip to delete downloaded
24+
# .whl files and temporary installers immediately after installation, keeping the container image ultra-lean.
25+
RUN pip install --no-cache-dir -r requirements.txt
26+
27+
# 5. Source Code Copying
28+
# Copies the entire content of your current local directory (test suites, conftest.py, schemas)
29+
# into the container's working directory.
30+
# Note: Ensure you have a .dockerignore file configured to prevent copying local artifacts
31+
# like .venv/ or __pycache__ folders into this layer.
32+
COPY . .
33+
34+
# 6. Default Container Command
35+
# Defines the primary instruction that will trigger automatically whenever the container is spun up.
36+
# Using the preferred JSON array syntax (exec form), it fires up the Pytest test runner in verbose mode (-v).
37+
# This default behavior can easily

requirements.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# ======= FILE CREATED BY FERNANDA BASTOS (@codebyfernanda) =======
2+
3+
pytest==9.0.3
4+
pytest-schema==0.1.2
5+
jsonschema==4.26.0
6+
requests==2.34.2
7+
8+
# =================================================================

0 commit comments

Comments
 (0)