File tree Expand file tree Collapse file tree 3 files changed +34
-6
lines changed
Expand file tree Collapse file tree 3 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 3636 run : |
3737 docker build -t flask-ci-app .
3838
39- - name : Run tests inside Docker
39+ - name : Run tests inside Docker (test stage)
4040 run : |
41- docker run --rm flask-ci-app pytest
41+ docker build --target test -t flask-ci-test .
42+ docker run --rm flask-ci-test
43+
44+ - name : Build production Docker image
45+ run : |
46+ docker build --target runtime -t flask-ci-app .
Original file line number Diff line number Diff line change 1- FROM python:3.12-slim
1+ # ================================
2+ # Stage 1: Test Stage
3+ # ================================
4+ FROM python:3.12-slim AS test-stage
25
36WORKDIR /app
7+ COPY requirements.txt requirements-dev.txt ./
8+
9+ RUN pip install --no-cache-dir -r requirements.txt \
10+ && pip install --no-cache-dir -r requirements-dev.txt
411
512COPY . .
13+ ENV PYTHONPATH=/app
14+ CMD ["pytest" ]
615
7- RUN pip install --no-cache-dir -r requirements.txt \
8- && pip install pytest
16+ # ================================
17+ # Stage 2: Production Stage
18+ # ================================
19+ FROM python:3.12-slim AS runtime
20+
21+ WORKDIR /app
22+
23+ COPY requirements.txt ./
24+
25+ RUN pip install --no-cache-dir -r requirements.txt
26+
27+ COPY app ./app
28+ COPY app.py ./
929
1030ENV PYTHONPATH=/app
1131
12- CMD ["python" , "app.py" ]
32+ EXPOSE 5000
33+
34+ CMD ["python" , "app.py" ]
Original file line number Diff line number Diff line change 1+ pytest
You can’t perform that action at this time.
0 commit comments