ashwinR commited on
Commit
7ce49a9
1 Parent(s): 316a52b

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -22
Dockerfile CHANGED
@@ -1,37 +1,34 @@
1
- FROM python:3.9-alpine AS builder
2
 
3
  WORKDIR /app
4
 
5
  COPY ./pyproject.toml .
6
  COPY ./poetry.lock .
7
 
8
- RUN apk add gcc musl-dev python3-dev libffi-dev openssl-dev cargo g++ libxslt-dev postgresql-dev build-base
9
- RUN apt update
10
- RUN apt install redis-server
11
- RUN redis-server --daemonize yes
12
- RUN redis-cli ping
 
13
 
14
- RUN apt-get install postgresql
15
- RUN service postgresql start
16
- RUN apt-get -y install postgresql
17
 
18
- RUN pip install poetry
19
- RUN poetry export --without-hashes -f requirements.txt --output requirements.txt
20
- RUN pip install -U -q pyngrok ipython psycopg2 alembic
21
 
22
- RUN sudo -u postgres psql -c "CREATE USER postadmin WITH PASSWORD 'postpass'";
23
- RUN sudo -u postgres psql -c "CREATE DATABASE siksalaya;"
24
- RUN sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE sikshyalaya TO postadmin;"
 
 
25
 
26
- RUN alembic revision --autogenerate -m "migrations"
27
- RUN alembic upgrade head
28
- FROM python:3.9-alpine
29
- RUN apk add libpq
30
 
31
- WORKDIR /app
32
  COPY ./ .
33
- #RUN mv ./misc/etc/gunicorn.conf.py .
34
 
 
35
  EXPOSE 7860
36
 
37
- CMD ["gunicorn", "main:app", "-w", "4", "--bind", "127.0.0.1:7860"]
 
1
+ FROM python:3.9-slim AS builder
2
 
3
  WORKDIR /app
4
 
5
  COPY ./pyproject.toml .
6
  COPY ./poetry.lock .
7
 
8
+ # Install build dependencies
9
+ RUN apt-get update \
10
+ && apt-get install -y --no-install-recommends build-essential \
11
+ && pip install --upgrade pip poetry \
12
+ && poetry config virtualenvs.create false \
13
+ && poetry install --no-interaction --no-ansi
14
 
15
+ FROM python:3.9-slim
 
 
16
 
17
+ WORKDIR /app
 
 
18
 
19
+ # Install runtime dependencies
20
+ RUN apt-get update \
21
+ && apt-get install -y --no-install-recommends libpq5 \
22
+ && apt-get clean \
23
+ && rm -rf /var/lib/apt/lists/*
24
 
25
+ # Copy the built virtual environment from the builder stage
26
+ COPY --from=builder /usr/local /usr/local
 
 
27
 
28
+ # Copy the rest of the backend files to the container
29
  COPY ./ .
 
30
 
31
+ # Expose the backend port (change this if your FastAPI app uses a different port)
32
  EXPOSE 7860
33
 
34
+ CMD ["gunicorn", "main:app", "-w", "4", "--bind", "0.0.0.0:7860"]