ashwinR commited on
Commit
4565280
1 Parent(s): 0c29cc6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +7 -5
Dockerfile CHANGED
@@ -19,6 +19,7 @@ WORKDIR /app
19
  # Install runtime dependencies
20
  RUN apt-get update \
21
  && apt-get install -y --no-install-recommends libpq5 redis-server \
 
22
  && apt-get clean \
23
  && rm -rf /var/lib/apt/lists/*
24
 
@@ -40,8 +41,6 @@ COPY --from=builder /usr/local /usr/local
40
  # Copy the rest of the backend files to the container
41
  COPY ./ .
42
 
43
- # Start Redis server and PostgreSQL in the background
44
- RUN service redis-server start
45
 
46
  # Switch back to a non-root user for security
47
  USER appuser
@@ -50,9 +49,12 @@ USER appuser
50
  #RUN pip install -U -q pyngrok ipython psycopg2 alembic
51
 
52
  # Create PostgreSQL users and databases in the background
53
- RUN sudo -c "psql -c \"CREATE USER postadmin WITH PASSWORD 'postpass';\"" postgres &
54
- RUN sudo -c "psql -c \"CREATE DATABASE siksalaya;\"" postgres &
55
- RUN sudo -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE sikshyalaya TO postadmin;\"" postgres &
 
 
 
56
 
57
  # Start the FastAPI app using Uvicorn
58
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
19
  # Install runtime dependencies
20
  RUN apt-get update \
21
  && apt-get install -y --no-install-recommends libpq5 redis-server \
22
+ && apt-get install postgresql
23
  && apt-get clean \
24
  && rm -rf /var/lib/apt/lists/*
25
 
 
41
  # Copy the rest of the backend files to the container
42
  COPY ./ .
43
 
 
 
44
 
45
  # Switch back to a non-root user for security
46
  USER appuser
 
49
  #RUN pip install -U -q pyngrok ipython psycopg2 alembic
50
 
51
  # Create PostgreSQL users and databases in the background
52
+ RUN service redis-server start \
53
+ && service postgresql start \
54
+ && sudo -u postgres psql -c "CREATE USER postadmin WITH PASSWORD 'postpass';" \
55
+ && sudo -u postgres psql -c "CREATE DATABASE siksalaya;" \
56
+ && sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE sikshyalaya TO postadmin;"
57
+
58
 
59
  # Start the FastAPI app using Uvicorn
60
  CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]