Skip to content

Commit f7c007e

Browse files
Dockerfile debug (#201)
* [wip] use of uv and adapt dockerfile * [wip] update actions to debug on branch * [wip] change build imaage yaml * [wip] install git in dockerfile (temoporarily)
1 parent 811cc65 commit f7c007e

2 files changed

Lines changed: 29 additions & 30 deletions

File tree

.github/workflows/build-image.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- main
7+
- dockerfile-debug
78
tags:
89
- "*"
9-
# Allows you to run this workflow manually from the Actions tab
1010
workflow_dispatch:
1111

1212
jobs:
@@ -24,10 +24,9 @@ jobs:
2424
with:
2525
images: thomasfaria/codification-ape-api
2626
tags: |
27-
# set latest tag for main branch
28-
type=raw,value=v1.0.1,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
29-
# propagate valid semver tags
30-
type=semver,pattern={{raw}}
27+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
28+
type=ref,event=branch
29+
type=ref,event=tag
3130
3231
- name: Set up QEMU
3332
uses: docker/setup-qemu-action@v3
@@ -50,8 +49,8 @@ jobs:
5049
tags: ${{ steps.meta.outputs.tags }}
5150
labels: ${{ steps.meta.outputs.labels }}
5251
build-args: |
53-
"API_USERNAME=${{ secrets.API_USERNAME }}"
54-
"API_PASSWORD=${{ secrets.API_PASSWORD }}"
52+
API_USERNAME=${{ secrets.API_USERNAME }}
53+
API_PASSWORD=${{ secrets.API_PASSWORD }}
5554
5655
- name: Image digest
5756
run: echo ${{ steps.docker_build.outputs.digest }}

Dockerfile

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
FROM python:3.12
22

3-
ARG API_USERNAME
4-
ARG API_PASSWORD
5-
ENV API_USERNAME ${API_USERNAME}
6-
ENV API_PASSWORD ${API_PASSWORD}
7-
ENV TIMEOUT=300
8-
# set api as the current work dir
9-
WORKDIR /api
10-
11-
# copy the requirements list
12-
COPY requirements.txt requirements.txt
13-
14-
# install all the requirements and import corpus
15-
RUN pip install --no-cache-dir --upgrade -r requirements.txt && \
16-
python -m nltk.downloader stopwords
17-
18-
# copy the main code of fastapi
19-
COPY ./app /api/app
20-
21-
# launch the unicorn server to run the api
22-
# If you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik,
23-
# add the option --proxy-headers, this will tell Uvicorn to trust the headers sent by that proxy telling it
24-
# that the application is running behind HTTPS, etc.
25-
CMD ["uvicorn", "app.main:codification_ape_app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "--timeout-graceful-shutdown", "300"]
3+
# Install system dependencies, including Git
4+
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
5+
6+
# Set working directory inside `src/`
7+
WORKDIR /api/src
8+
9+
# Copy pyproject.toml and lockfile for dependency resolution
10+
COPY pyproject.toml uv.lock ./
11+
12+
# Install uv package manager
13+
RUN pip install uv
14+
15+
# Sync dependencies
16+
RUN uv sync
17+
18+
# Copy application code
19+
COPY ./src /api/src
20+
21+
# Expose port 5000
22+
EXPOSE 5000
23+
24+
# Start FastAPI application
25+
CMD ["uv", "run", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "5000"]

0 commit comments

Comments
 (0)