Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions .github/workflows/build-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
push:
branches:
- main
- dockerfile-debug
tags:
- "*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
Expand All @@ -24,10 +24,9 @@ jobs:
with:
images: thomasfaria/codification-ape-api
tags: |
# set latest tag for main branch
type=raw,value=v1.0.1,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# propagate valid semver tags
type=semver,pattern={{raw}}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=ref,event=branch
type=ref,event=tag

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
Expand All @@ -50,8 +49,8 @@ jobs:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
"API_USERNAME=${{ secrets.API_USERNAME }}"
"API_PASSWORD=${{ secrets.API_PASSWORD }}"
API_USERNAME=${{ secrets.API_USERNAME }}
API_PASSWORD=${{ secrets.API_PASSWORD }}

- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
46 changes: 23 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
FROM python:3.12

ARG API_USERNAME
ARG API_PASSWORD
ENV API_USERNAME ${API_USERNAME}
ENV API_PASSWORD ${API_PASSWORD}
ENV TIMEOUT=300
# set api as the current work dir
WORKDIR /api

# copy the requirements list
COPY requirements.txt requirements.txt

# install all the requirements and import corpus
RUN pip install --no-cache-dir --upgrade -r requirements.txt && \
python -m nltk.downloader stopwords

# copy the main code of fastapi
COPY ./app /api/app

# launch the unicorn server to run the api
# If you are running your container behind a TLS Termination Proxy (load balancer) like Nginx or Traefik,
# add the option --proxy-headers, this will tell Uvicorn to trust the headers sent by that proxy telling it
# that the application is running behind HTTPS, etc.
CMD ["uvicorn", "app.main:codification_ape_app", "--proxy-headers", "--host", "0.0.0.0", "--port", "80", "--timeout-graceful-shutdown", "300"]
# Install system dependencies, including Git
RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*

# Set working directory inside `src/`
WORKDIR /api/src

# Copy pyproject.toml and lockfile for dependency resolution
COPY pyproject.toml uv.lock ./

# Install uv package manager
RUN pip install uv

# Sync dependencies
RUN uv sync

# Copy application code
COPY ./src /api/src

# Expose port 5000
EXPOSE 5000

# Start FastAPI application
CMD ["uv", "run", "uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "5000"]