File size: 2,208 Bytes
0b4e916
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# FYI This deployement will take about 40 minutes without any logs.
# Due to sentence-transformers - |torch| nvidiacu11 other nvidia etc.
# Use the official Python 3.9 image
#FROM python:3.9
FROM ubuntu:latest
RUN apt update
RUN apt-get upgrade -y
RUN apt-get install -y python3-pip python-dev-is-python3 libmysqlclient-dev 
RUN apt-get install -y gcc default-libmysqlclient-dev pkg-config 
RUN apt install graphviz libgraphviz-dev -y
RUN rm -rf /var/lib/apt/lists/*

# TODO  Install Conda
# Install base utilities
RUN apt-get update \
    && apt-get install -y build-essential \
    && apt-get install -y wget \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Install miniconda
ENV CONDA_DIR /opt/conda
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh && \
    /bin/bash ~/miniconda.sh -b -p /opt/conda

# Put conda in path so we can use conda activate
ENV PATH=$CONDA_DIR/bin:$PATH

# Insta
RUN export PYTHONPATH=$PWD

# Set the working directory to /code
WORKDIR /code
#VOLUME /home/amari/Desktop/CaesarAI/CaesarFastAPI /code
# Copy the current directory contents into the container at /code
COPY ./environment.yml /code/environment.yml
 
# Install requirements.txt 
RUN conda env create -f /code/environment.yml
RUN conda init bash
#RUN conda activate caesaraicontractqa

# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
# Switch to the "user" user
USER user
# Set home to the user's home directory
ENV HOME=/home/user \
	PATH=/home/user/.local/bin:$PATH

# Set the working directory to the user's home directory
WORKDIR $HOME/app

# Copy the current directory contents into the container at $HOME/app setting the owner to the user
COPY --chown=user . $HOME/app
# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "caesaraicontractqa", "/bin/bash", "-c"]
# Local
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860","--reload"] 
# Fly.io
#CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8080","--reload"] 
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "caesaraicontractqa", "uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860","--reload"]