File tree Expand file tree Collapse file tree 2 files changed +50
-13
lines changed Expand file tree Collapse file tree 2 files changed +50
-13
lines changed Original file line number Diff line number Diff line change
1
+ # Use an official Python runtime as a base image
2
+ FROM python:3.12
3
+
4
+ ENV PYTHONUNBUFFERED=1
5
+
6
+ # Set the working directory inside the container
7
+ WORKDIR /app
8
+
9
+ # Install system dependencies
10
+ RUN apt-get update && \
11
+ apt-get install -y --no-install-recommends gcc curl gnupg2 && \
12
+ apt-get clean && \
13
+ rm -rf /var/lib/apt/lists/*
14
+
15
+ # Install Poetry
16
+ RUN curl -sSL https://install.python-poetry.org | python3 -
17
+
18
+ # Add Poetry to PATH
19
+ ENV PATH="${PATH}:/root/.local/bin"
20
+
21
+ # Copy only the pyproject.toml and poetry.lock to leverage Docker cache
22
+ COPY pyproject.toml poetry.lock /app/
23
+
24
+ # Install project dependencies
25
+ RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi
26
+
27
+ # Copy the entire Django project to the working directory
28
+ COPY . /app/
29
+
30
+ # Expose the port your application will run on
31
+ EXPOSE 8000
32
+
33
+ # Command to run the Django server
34
+ CMD ["python" , "manage.py" , "runserver" , "0.0.0.0:8000" ]
Original file line number Diff line number Diff line change 1
- version : ' 3.8 ' # Use the version of Docker Compose that you need
1
+ version : " 3.9 " # Use the version of Docker Compose that you need
2
2
3
3
services :
4
- postgresdb :
5
- image : postgres:latest # Use the latest PostgreSQL image
6
- container_name : postgresdb # Name your container
4
+ db :
5
+ image : postgres # Use the latest PostgreSQL image
6
+ volumes :
7
+ - ./data/db:/var/lib/postgresql/data
7
8
environment :
8
- POSTGRES_USER : yourusername # Set the username for the PostgreSQL database
9
- POSTGRES_PASSWORD : yourpassword # Set the password for the PostgreSQL database
10
- POSTGRES_DB : yourdatabase # Set the name of the database
9
+ - POSTGRES_USER= yourusername # Set the username for the PostgreSQL database
10
+ - POSTGRES_PASSWORD= yourpassword # Set the password for the PostgreSQL database
11
+ - POSTGRES_DB= yourdatabase # Set the name of the database
11
12
ports :
12
13
- " 5432:5432" # Map the PostgreSQL port to the host
14
+ backend :
15
+ build : ./backend
16
+ command : python manage.py runserver 0.0.0.0:8000
13
17
volumes :
14
- - postgres_data:/var/lib/postgresql/data # Persist the data using a named volume
15
-
16
- volumes :
17
- postgres_data :
18
- driver : local # Use the local driver for the volume
19
-
18
+ - .:/code
19
+ ports :
20
+ - " 8000:8000"
21
+ depends_on :
22
+ - db
You can’t perform that action at this time.
0 commit comments