Skip to content

Commit

Permalink
Merge pull request #2 from fpgmaas/prod
Browse files Browse the repository at this point in the history
Add building for CPU
  • Loading branch information
fpgmaas authored Jun 18, 2024
2 parents ace1466 + 535a8bf commit 1f29889
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 7 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build and Push Docker Images

on:
workflow_dispatch:

jobs:
push-to-acr:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to Azure Container Registry
uses: azure/docker-login@v1
with:
login-server: pypiscoutacr.azurecr.io
username: ${{ secrets.ACR_USERNAME }}
password: ${{ secrets.ACR_PASSWORD }}

- name: Build and Push Backend Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./DockerfileCPU
platforms: linux/amd64
push: true
tags: pypiscoutacr.azurecr.io/pypi-scout-backend:latest

- name: Build and Push Frontend Docker image
uses: docker/build-push-action@v4
with:
context: ./frontend
file: ./frontend/Dockerfile
platforms: linux/amd64
push: true
tags: pypiscoutacr.azurecr.io/pypi-scout-frontend:latest
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,31 @@ FROM python:3.10-slim-bookworm
ENV POETRY_VERSION=1.6 \
POETRY_VIRTUALENVS_CREATE=false

# Install poetry
RUN pip install "poetry==$POETRY_VERSION"
# Install poetry and clean up
RUN pip install "poetry==$POETRY_VERSION" && \
rm -rf /root/.cache/pip

# Copy only requirements to cache them in docker layer
# Set work directory
WORKDIR /code

# Copy only requirements to cache them in docker layer
COPY poetry.lock pyproject.toml /code/

# Project initialization:
RUN poetry install --no-interaction --no-ansi --no-root --no-dev
# Install project dependencies and clean up
RUN poetry install --no-interaction --no-ansi --no-root --no-dev && \
rm -rf /root/.cache/pip

# Copy Python code to the Docker image
COPY pypi_scout /code/pypi_scout/

ENV PYTHONPATH=/code

# Copy the start script and make executable
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Make empty data directory
RUN mkdir -p /code/data

ENV PYTHONPATH=/code

# Use the script as the entrypoint
ENTRYPOINT ["/start.sh"]
34 changes: 34 additions & 0 deletions DockerfileCPU
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# syntax=docker/dockerfile:1

# Use a slim Python image as the base
FROM python:3.10-slim-bookworm

# Set environment variables
ENV PYTHONUNBUFFERED=1

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
&& apt-get clean && rm -rf /var/lib/apt/lists/*

# Set working directory
WORKDIR /code

# Copy only requirements to cache them in docker layer
COPY requirements-cpu.txt /code/requirements-cpu.txt

# Install Python dependencies
RUN pip install --no-cache-dir -r requirements-cpu.txt

# Copy the rest of the application code
COPY pypi_scout /code/pypi_scout/

# Copy the start script and make it executable
COPY start.sh /start.sh
RUN chmod +x /start.sh

# Make empty data directory
RUN mkdir -p /code/data

# Use the script as the entrypoint
ENTRYPOINT ["/start.sh"]
14 changes: 14 additions & 0 deletions requirements-cpu.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
beautifulsoup4==4.12.3
polars==0.20.31
sentence-transformers==3.0.1
lxml==5.2.2
python-dotenv==1.0.1
pinecone-client==4.0.0
tqdm==4.66.4
fastapi==0.111.0
pydantic==2.7.4
uvicorn==0.30.1
gdown==5.2.0
torch==2.0.1
--index-url=https://download.pytorch.org/whl/cpu
--extra-index-url=https://pypi.org/simple

0 comments on commit 1f29889

Please sign in to comment.