Merge pull request 'feat: update Dockerfile and requirements for ML dependencies; add base image build workflow' (#2) from dev into main
Reviewed-on: #2
This commit is contained in:
		
						commit
						7afd7f0832
					
				
					 5 changed files with 64 additions and 20 deletions
				
			
		
							
								
								
									
										37
									
								
								.gitea/workflows/build-base.yml
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								.gitea/workflows/build-base.yml
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
name: Build Worker Base Image
 | 
			
		||||
 | 
			
		||||
on:
 | 
			
		||||
  workflow_dispatch:
 | 
			
		||||
  push:
 | 
			
		||||
    paths:
 | 
			
		||||
      - 'Dockerfile.base'
 | 
			
		||||
      - 'requirements.base.txt'
 | 
			
		||||
    branches:
 | 
			
		||||
      - main
 | 
			
		||||
 | 
			
		||||
jobs:
 | 
			
		||||
  build-base:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    permissions:
 | 
			
		||||
      packages: write
 | 
			
		||||
    steps:
 | 
			
		||||
      - name: Checkout code
 | 
			
		||||
        uses: actions/checkout@v3
 | 
			
		||||
 | 
			
		||||
      - name: Set up Docker Buildx
 | 
			
		||||
        uses: docker/setup-buildx-action@v2
 | 
			
		||||
 | 
			
		||||
      - name: Login to GitHub Container Registry
 | 
			
		||||
        uses: docker/login-action@v3
 | 
			
		||||
        with:
 | 
			
		||||
          registry: git.siwatsystem.com
 | 
			
		||||
          username: ${{ github.actor }}
 | 
			
		||||
          password: ${{ secrets.RUNNER_TOKEN }}
 | 
			
		||||
        
 | 
			
		||||
      - name: Build and push base Docker image
 | 
			
		||||
        uses: docker/build-push-action@v4
 | 
			
		||||
        with:
 | 
			
		||||
          context: .
 | 
			
		||||
          file: ./Dockerfile.base
 | 
			
		||||
          push: true
 | 
			
		||||
          tags: git.siwatsystem.com/adsist-cms/worker-base:latest
 | 
			
		||||
							
								
								
									
										16
									
								
								Dockerfile
									
										
									
									
									
								
							
							
						
						
									
										16
									
								
								Dockerfile
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,19 +1,11 @@
 | 
			
		|||
# Use the official Python image from the Docker Hub
 | 
			
		||||
FROM python:3.13-bookworm
 | 
			
		||||
# Use our pre-built base image with ML dependencies
 | 
			
		||||
FROM git.siwatsystem.com/adsist-cms/worker-base:latest
 | 
			
		||||
 | 
			
		||||
# Set the working directory in the container
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
# Copy the requirements file into the container at /app
 | 
			
		||||
# Copy and install application requirements (frequently changing dependencies)
 | 
			
		||||
COPY requirements.txt .
 | 
			
		||||
 | 
			
		||||
# Update apt, install libgl1, and clear apt cache
 | 
			
		||||
RUN apt update && apt install -y libgl1 && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
# Install any dependencies specified in requirements.txt
 | 
			
		||||
RUN pip install --no-cache-dir -r requirements.txt
 | 
			
		||||
 | 
			
		||||
# Copy the rest of the application code into the container at /app
 | 
			
		||||
# Copy the application code
 | 
			
		||||
COPY . .
 | 
			
		||||
 | 
			
		||||
# Run the application
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										15
									
								
								Dockerfile.base
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								Dockerfile.base
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,15 @@
 | 
			
		|||
# Base image with all ML dependencies
 | 
			
		||||
FROM python:3.13-bookworm
 | 
			
		||||
 | 
			
		||||
# Install system dependencies
 | 
			
		||||
RUN apt update && apt install -y libgl1 && rm -rf /var/lib/apt/lists/*
 | 
			
		||||
 | 
			
		||||
# Copy and install base requirements (ML dependencies that rarely change)
 | 
			
		||||
COPY requirements.base.txt .
 | 
			
		||||
RUN pip install --no-cache-dir -r requirements.base.txt
 | 
			
		||||
 | 
			
		||||
# Set working directory
 | 
			
		||||
WORKDIR /app
 | 
			
		||||
 | 
			
		||||
# This base image will be reused for all worker builds
 | 
			
		||||
CMD ["python3", "-m", "fastapi", "run", "--host", "0.0.0.0", "--port", "8000"]
 | 
			
		||||
							
								
								
									
										7
									
								
								requirements.base.txt
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								requirements.base.txt
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,7 @@
 | 
			
		|||
torch
 | 
			
		||||
torchvision
 | 
			
		||||
ultralytics
 | 
			
		||||
opencv-python
 | 
			
		||||
scipy
 | 
			
		||||
filterpy
 | 
			
		||||
psycopg2-binary
 | 
			
		||||
| 
						 | 
				
			
			@ -1,13 +1,6 @@
 | 
			
		|||
fastapi
 | 
			
		||||
uvicorn
 | 
			
		||||
torch
 | 
			
		||||
torchvision
 | 
			
		||||
ultralytics
 | 
			
		||||
opencv-python
 | 
			
		||||
websockets
 | 
			
		||||
fastapi[standard]
 | 
			
		||||
redis
 | 
			
		||||
urllib3<2.0.0
 | 
			
		||||
psycopg2-binary
 | 
			
		||||
scipy
 | 
			
		||||
filterpy
 | 
			
		||||
urllib3<2.0.0
 | 
			
		||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue