django-zadatak/Dockerfile.prod
2024-01-15 11:49:58 +01:00

40 lines
1.2 KiB
Docker

# Use an official Python runtime as a parent image
FROM python:3.8-slim
# Set environment variables for Django
ENV DJANGO_SETTINGS_MODULE=plovidba_projekt.settings
ENV PYTHONUNBUFFERED 1
# Install PostgreSQL development headers, build tools, and other dependencies
RUN apt-get update && \
apt-get install -y libpq-dev gcc && \
apt-get clean
# Install GDAL
RUN apt-get update \
&& apt-get install -y binutils libproj-dev gdal-bin
# Install PostgreSQL client and PostGIS extension
RUN apt-get update && \
apt-get install -y postgresql-client postgis && \
apt-get clean
# .Create and set the working directory in the container
RUN mkdir -p /app/plovidba_projekt
WORKDIR /app/plovidba_projekt
# .Copy the requirements file into the container and install dependencies
COPY requirements.txt /app/plovidba_projekt/
RUN pip install -r requirements.txt
# .Copy the rest of the application code into the container
COPY . /app/plovidba_projekt/
VOLUME /app/media
VOLUME /app/static
# Expose the port the application will run on (if necessary)
EXPOSE 8000
# Run the Django application using Gunicorn in production mode
CMD ["gunicorn", "plovidba_projekt.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "4"]