File size: 1,358 Bytes
a9b39d2
2926041
 
a9b39d2
2926041
 
 
 
 
 
2ccde67
 
 
2926041
 
a9b39d2
 
2926041
a9b39d2
 
2926041
 
 
 
 
 
 
2ccde67
 
 
 
 
 
 
 
 
 
 
 
a9b39d2
2ccde67
 
 
a9b39d2
2926041
2ccde67
a9b39d2
9dd4b6c
212f451
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Use an official Python runtime as a parent image
FROM python:3.10-slim-bullseye

# Set Python to use unbuffered mode
ENV PYTHONUNBUFFERED=1
ENV PATH="/var/www/.local/bin:${PATH}"

# Create a non-root user
RUN useradd -m -u 1000 -U -s /bin/bash myuser

# Install system dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    python3-pip python3-dev git && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory in the container
RUN mkdir /var/www
ENV HOME=/var/www
WORKDIR /var/www

# Change ownership of /var/www to the non-root user
RUN chown -R myuser:myuser /var/www

# Switch to the non-root user
USER myuser

# Copy the current directory contents into the container at /var/www
COPY --chown=myuser:myuser . /var/www

# Install dependencies
RUN pip install --no-cache-dir -r requirements.txt && \
    pip install --no-cache-dir transformers sentencepiece

# Define tokenizer name
ARG TOKENIZER_NAME=unsloth/Llama-3.3-70B-Instruct
ENV TOKENIZER_NAME=${TOKENIZER_NAME}

ARG APP_PORT=7860
ENV APP_PORT=${APP_PORT}

# Download the tokenizer and store it in the image
RUN python -c "from transformers import AutoTokenizer; \
    AutoTokenizer.from_pretrained('${TOKENIZER_NAME}')"

# Expose the port
EXPOSE ${APP_PORT}

# Run FastAPI app with Uvicorn
CMD ["sh", "-c", "uvicorn main:app --host 0.0.0.0 --port $APP_PORT"]