ashwinR commited on
Commit
a799081
·
1 Parent(s): da725d6

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +27 -33
Dockerfile CHANGED
@@ -1,42 +1,36 @@
 
1
  FROM python:3.9-slim
2
 
3
- COPY . /app
4
  WORKDIR /app
5
 
6
- COPY ./pyproject.toml .
7
- COPY ./poetry.lock .
8
-
9
- # Install build dependencies
10
- RUN apt-get update \
11
- && apt-get install -y --no-install-recommends build-essential \
12
- && pip install --upgrade pip poetry \
13
- && poetry config virtualenvs.create false \
14
- && poetry install --no-interaction --no-ansi
15
-
16
- # Install runtime dependencies
17
- RUN apt-get update \
18
- && apt-get install -y --no-install-recommends redis-server postgresql \
19
- && apt-get clean \
20
- && rm -rf /var/lib/apt/lists/*
21
-
22
- # Start Redis and Postgres
23
- RUN service redis-server start
24
- RUN service postgresql start
25
-
26
- # Create user, database, and grant privileges
27
- #RUN su postgres -c "psql -c \"CREATE USER postadmin WITH PASSWORD 'postpass';\""
28
- #RUN su postgres -c "psql -c \"CREATE DATABASE siksalaya;\""
29
- #RUN su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE siksalaya TO postadmin;\""
30
 
31
- # Set environment variables for Alembic
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  ENV DATABASE_URL=postgresql://postadmin:postpass@localhost/siksalaya
33
 
34
- RUN ls
35
-
36
- RUN alembic revision --autogenerate -m "migrations"
37
 
38
- # Run Alembic migrations
39
- #RUN alembic upgrade head
 
40
 
41
- # Start the FastAPI app using Uvicorn
42
- CMD ["bash", "-c", "redis-server --daemonize yes && uvicorn app:app --host 0.0.0.0 --port 7860"]
 
1
+ # Use an official Python runtime as a parent image
2
  FROM python:3.9-slim
3
 
4
+ # Set the working directory in the container
5
  WORKDIR /app
6
 
7
+ # Copy the current directory contents into the container
8
+ COPY . /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ # Install any needed packages specified in requirements.txt
11
+ RUN apt-get update && apt-get install -y --no-install-recommends \
12
+ build-essential \
13
+ supervisor \
14
+ postgresql \
15
+ redis-server && \
16
+ pip install --upgrade pip poetry && \
17
+ poetry config virtualenvs.create false && \
18
+ poetry install --no-interaction --no-ansi && \
19
+ apt-get clean && \
20
+ rm -rf /var/lib/apt/lists/*
21
+
22
+ # Copy supervisor configuration
23
+ COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
24
+
25
+ # Set environment variable
26
  ENV DATABASE_URL=postgresql://postadmin:postpass@localhost/siksalaya
27
 
28
+ # Make port 80 available to the world outside this container
29
+ EXPOSE 80
 
30
 
31
+ # Add and give execution permissions to the startup script
32
+ COPY start.sh start.sh
33
+ RUN chmod +x start.sh
34
 
35
+ # Start services
36
+ CMD ["/app/start.sh"]