-
Notifications
You must be signed in to change notification settings - Fork 39
/
Dockerfile
65 lines (54 loc) · 1.77 KB
/
Dockerfile
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
# Use an official Python runtime as a parent image
FROM python:3.11-slim-buster as codex_base
# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# Set work directory in the container
WORKDIR /app
# Install system dependencies
RUN apt-get update \
&& apt-get install -y build-essential curl ffmpeg wget libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& wget https://github.com/git/git/archive/v2.28.0.tar.gz -O git.tar.gz \
&& tar -zxf git.tar.gz \
&& cd git-* \
&& make prefix=/usr all \
&& make prefix=/usr install
# Install Poetry - respects $POETRY_VERSION & $POETRY_HOME
ENV POETRY_VERSION=1.1.8 \
POETRY_HOME="/opt/poetry" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
PATH="$POETRY_HOME/bin:$PATH"
RUN pip3 install poetry
# Copy only requirements to cache them in Docker layer
WORKDIR /app
COPY pyproject.toml poetry.lock* /app/
RUN mkdir /app/codex
RUN touch /app/codex/__init__.py
RUN touch /app/README.md
# Project initialization:
RUN poetry install --no-interaction --no-ansi
FROM codex_base as codex_db
# Caching prisma generate step
COPY schema.prisma /app/
COPY migrations /app/migrations
RUN prisma generate
FROM codex_db as codex
# Fast build of codex - only needs to update the python code
COPY . /app
# Set a default value (this can be overridden)
ENV PORT=8000
# Just declare the variable, the value will be set when running the container
ENV OPENAI_API_KEY=""
ENV RUN_ENV=""
ENV USER_DB_ADMIN=""
ENV USER_DB_PASS=""
ENV USER_DB_HOST=""
ENV USER_CONN_NAME=""
ENV LANGCHAIN_PROJECT=""
ENV LANGCHAIN_TRACING_V2=""
ENV LANGCHAIN_API_KEY=""
# This will be the command to run the FastAPI server using uvicorn
CMD ./run serve