File size: 2,047 Bytes
0891867
370afab
895bd1b
0891867
 
895bd1b
0891867
 
895bd1b
0891867
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9989061
 
 
 
 
 
 
 
 
 
0891867
 
 
895bd1b
0891867
 
2a98105
 
 
0891867
 
 
 
895bd1b
0891867
 
9989061
895bd1b
 
 
0891867
 
505fb08
895bd1b
0891867
505fb08
895bd1b
0891867
e05da78
cef9c21
895bd1b
0891867
505fb08
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# # Use Python 3.10 slim as base image
FROM python:3.10-slim

# # Set the working directory
# WORKDIR /app

# # Copy the current directory contents into the container at /app
# COPY . /app

# # Install dependencies
# RUN apt-get update && apt-get install -y \
#     python3-pip \
#     git

# # Install pip packages without caching
# RUN pip install --no-cache-dir --upgrade pip
# RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
# RUN pip install --no-cache-dir -r requirements.txt

# # # Copy .env file to the working directory
# # COPY .env /app/.env

# # # Set environment variables from .env file
# # ENV $(cat /app/.env | xargs)

# # Expose port 7860
# EXPOSE 7860



# # Run the application
# CMD ["python", "app.py"]

# Set environment variables
ENV PYTHONUNBUFFERED=TRUE
ENV PYTHONDONTWRITEBYTECODE=TRUE
ENV PATH="/opt/conda/bin:${PATH}"

# Get args for AWS credentials
ARG AWS_ACCESS_KEY_ID
ARG AWS_SECRET_ACCESS_KEY
ARG AWS_DEFAULT_REGION

# get args as env variables
ENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
ENV AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION}

# Install system dependencies
RUN apt-get update && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y \
    python3-pip \
    python3-dev \
    git \
    libomp-dev \
    libopenblas-dev \
    libblas-dev \
    && rm -rf /var/lib/apt/lists/*

# Set up working directory
WORKDIR /opt/ml/code

# Copy requirements and install dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip
RUN pip install --no-cache-dir torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu121
RUN pip install --no-cache-dir -r requirements.txt

# Copy the application code and serve script
COPY app.py .
COPY serve.sh .

# Make the serve script executable
RUN chmod +x serve.sh

# Expose the Gradio port
EXPOSE 8080
EXPOSE 7860

# Set entry point to the serve script
ENTRYPOINT ["./serve.sh"]