File size: 1,550 Bytes
d3abbf7
 
 
 
632bf0d
 
d3abbf7
632bf0d
d3abbf7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632bf0d
 
d3abbf7
632bf0d
d3abbf7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
###########
# BUILDER #
###########

ARG AWS_ACCOUNT_ID

# pull official base image
FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/gradio-python:3.11.10-slim as builder

# set work directory
WORKDIR /app

# set environment variables
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV OMP_NUM_THREADS=1


# install dependencies
RUN apt-get update \
    && apt-get -y install libpq-dev gcc \
    && pip install psycopg

RUN pip install --upgrade pip
COPY ./requirements.txt /app/requirements.txt
RUN pip wheel --no-cache-dir --no-deps --wheel-dir /app/wheels -r requirements.txt

#########
# FINAL #
#########

ARG AWS_ACCOUNT_ID

# pull official base image
FROM ${AWS_ACCOUNT_ID}.dkr.ecr.us-east-1.amazonaws.com/gradio-python:3.11.10-slim

# create directory for the app user
RUN mkdir -p /home/backend-app

# create the app user
RUN addgroup --system app && adduser --system --group app

# create the appropriate directories
ENV HOME=/home/app
ENV BACKEND_APP_HOME=/home/app
# RUN mkdir $BACKEND_APP_HOME
WORKDIR $BACKEND_APP_HOME

# install dependencies
RUN apt-get update \
    && apt-get -y install libpq-dev gcc \
    && pip install psycopg

COPY --from=builder /app/wheels /wheels
COPY --from=builder /app/requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache /wheels/*

# copy project
COPY . $BACKEND_APP_HOME

# chown all the files to the app user
RUN chown -R app:app $BACKEND_APP_HOME

# change to the app user
USER app

# Expose port
EXPOSE 7860
ENV GRADIO_SERVER_NAME="0.0.0.0"

CMD ["gradio", "app.py"]