Skip to content

Commit ef84919

Browse files
committed
Enhance Docker setup and configuration
- Updated GitHub Actions workflow to start Colima with specific resource allocations (CPU, memory, disk). - Modified Dockerfile to set memory configuration for PyTorch and added environment variables for memory management. - Improved Docker image build process in DockerRepository by specifying CPU and memory limits, and naming the container for better identification.
1 parent 4e35669 commit ef84919

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

.github/workflows/gbf_vector.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ jobs:
3131
run: |
3232
brew install --cask docker
3333
brew install colima
34-
brew services start colima
34+
colima start --cpu 4 --memory 16 --disk 100
35+
brew services restart colima
3536
3637
- name: Set up DOCKER_HOST as output
3738
id: docker-env

docker/Dockerfile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@ FROM python:3.11-slim
33
# Opcional: define la ruta de cache huggingface
44
ENV HF_HOME=/cache/huggingface
55

6+
# Configuración de memoria para PyTorch
7+
ENV PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512
8+
ENV MAX_MEMORY=8g
9+
610
# Instala dependencias necesarias
711
RUN apt-get update && apt-get install -y --no-install-recommends \
812
git \
9-
&& rm -rf /var/lib/apt/lists/*
13+
&& rm -rf /var/lib/apt/lists/*
1014

1115
# Crea directorios
1216
WORKDIR /app

src/data/repository/docker_repository.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,12 @@ export class DockerRepository {
5050
// Build the image with explicit tagging
5151
const stream = await this.docker.buildImage({
5252
context: this.dockerDir,
53-
src: ['Dockerfile', 'requirements.txt', 'main.py']
53+
src: ['Dockerfile', 'requirements.txt', 'main.py'],
5454
}, {
5555
t: 'fastapi-app:latest',
56+
cpusetcpus: 4,
57+
memory: 16384,
58+
memswap: 16384,
5659
dockerfile: 'Dockerfile',
5760
buildargs: {},
5861
nocache: true
@@ -106,7 +109,8 @@ export class DockerRepository {
106109
PortBindings: {
107110
'8000/tcp': [{ HostPort: '8000' }]
108111
}
109-
}
112+
},
113+
name: 'fastapi-app'
110114
});
111115

112116
logDebugInfo('🐳 🟡 Starting container...');

0 commit comments

Comments
 (0)