ashwinR commited on
Commit
1de79ab
1 Parent(s): 3e750a5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +12 -6
Dockerfile CHANGED
@@ -40,10 +40,16 @@ COPY --from=builder /usr/local /usr/local
40
  # Copy the rest of the backend files to the container
41
  COPY ./ .
42
 
43
- # Initialize PostgreSQL data directory and set permissions
44
- RUN mkdir -p /usr/local/pgsql/data \
45
- && chown -R postgres:postgres /usr/local/pgsql/data \
46
- && su -c "/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data" postgres
47
 
48
- # Start Redis server and PostgreSQL
49
- CMD ["bash", "-c", "redis-server --daemonize yes && su -c '/usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile' postgres && uvicorn app:app --host 0.0.0.0 --port 7860"]
 
 
 
 
 
 
 
 
 
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 && /usr/local/pgsql/bin/pg_ctl start -D /usr/local/pgsql/data -l logfile &
 
 
45
 
46
+ # Install additional Python dependencies
47
+ RUN pip install -U -q pyngrok ipython psycopg2 alembic
48
+
49
+ # Create PostgreSQL users and databases in the background
50
+ RUN su -c "psql -c \"CREATE USER postadmin WITH PASSWORD 'postpass';\"" postgres &
51
+ RUN su -c "psql -c \"CREATE DATABASE siksalaya;\"" postgres &
52
+ RUN su -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE sikshyalaya TO postadmin;\"" postgres &
53
+
54
+ # Start the FastAPI app using Uvicorn
55
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]