File size: 1,177 Bytes
3e986da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07eac76
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
FROM python:3.11.9-slim

# Expose the secret SECRETS at build-time
RUN --mount=type=secret,id=REDIS_URL,mode=0444,required=true
RUN --mount=type=secret,id=REDIS_USERNAME,mode=0444,required=true
RUN --mount=type=secret,id=REDIS_PASSWORD,mode=0444,required=true

# Read secrets and set environment variables
RUN export REDIS_URL=$(cat /run/secrets/REDIS_URL) \
    && export REDIS_USERNAME=$(cat /run/secrets/REDIS_USERNAME) \
    && export REDIS_PASSWORD=$(cat /run/secrets/REDIS_PASSWORD) \
    && echo "REDIS_URL=$REDIS_URL" >> /etc/environment \
    && echo "REDIS_USERNAME=$REDIS_USERNAME" >> /etc/environment \
    && echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> /etc/environment

# Source the environment file
RUN . /etc/environment

# Copy requirements file
COPY requirements.txt .

# Update pip
RUN pip --timeout=3000 install --no-cache-dir --upgrade pip

# Install dependecies
RUN pip --timeout=3000 install --no-cache-dir -r requirements.txt

# Make project directory
RUN mkdir -p /src/api/

# Set working directory
WORKDIR /src/api

# Copy API
COPY . .

# Expose app port
EXPOSE 7860

# Start application
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]