File size: 1,257 Bytes
e1969f9
b7a7f32
4336251
b7a7f32
6425f35
 
 
7ce49a9
 
 
 
 
 
63f7409
7ce49a9
 
e1969f9
7ce49a9
 
63f7409
e1969f9
 
 
c2113b3
5173a75
88874f4
 
 
c2113b3
e1969f9
5173a75
109da6a
382aeac
 
 
 
e1969f9
382aeac
e1969f9
1de79ab
bb57f2b
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
FROM python:3.9-slim

WORKDIR ./ /app

COPY ./pyproject.toml .
COPY ./poetry.lock .

# Install build dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends build-essential \
    && pip install --upgrade pip poetry \
    && poetry config virtualenvs.create false \
    && poetry install --no-interaction --no-ansi

# Install runtime dependencies
RUN apt-get update \
    && apt-get install -y --no-install-recommends redis-server postgresql \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

# Start Redis and Postgres
RUN service redis-server start
RUN service postgresql start

# Create user, database, and grant privileges
#RUN su postgres -c "psql -c \"CREATE USER postadmin WITH PASSWORD 'postpass';\""
#RUN su postgres -c "psql -c \"CREATE DATABASE siksalaya;\""
#RUN su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE siksalaya TO postadmin;\""

# Set environment variables for Alembic
ENV DATABASE_URL=postgresql://postadmin:postpass@localhost/siksalaya

RUN ls

RUN alembic revision --autogenerate -m "migrations"

# Run Alembic migrations
#RUN alembic upgrade head

# Start the FastAPI app using Uvicorn
CMD ["bash", "-c", "redis-server --daemonize yes && uvicorn app:app --host 0.0.0.0 --port 7860"]