made everything to a docker file
parent
812099ee7f
commit
2c286dacf4
|
|
@ -2,10 +2,13 @@
|
|||
*/__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
#added
|
||||
staticfiles/
|
||||
*/migrations/
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ from dotenv import load_dotenv
|
|||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
TEMPLATES_DIR = os.path.join(BASE_DIR + '/templates')
|
||||
|
||||
DEFAULT_AUTO_FIELD='django.db.models.AutoField'
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||
|
||||
|
|
@ -128,6 +130,7 @@ USE_TZ = True
|
|||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
||||
STATIC_URL = '/static/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR + '/media')
|
||||
MEDIA_URL = '/media/'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
# Use an official Python runtime as a parent image
|
||||
FROM python:3.11-slim
|
||||
|
||||
# Set environment variables
|
||||
ENV PYTHONDONTWRITEBYTECODE=1
|
||||
ENV PYTHONUNBUFFERED=1
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
|
||||
# Install system dependencies
|
||||
RUN apt-get update && apt-get install -y \
|
||||
build-essential \
|
||||
libpq-dev \
|
||||
default-libmysqlclient-dev \
|
||||
pkg-config \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Install Python dependencies
|
||||
COPY requirements.txt /app/
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
RUN pip install gunicorn
|
||||
|
||||
# Copy project files
|
||||
COPY . /app/
|
||||
|
||||
# Expose the port on which the application will run
|
||||
EXPOSE 3030
|
||||
|
||||
# Define environment variable for Gunicorn
|
||||
ENV GUNICORN_CMD_ARGS="--bind 0.0.0.0:3030"
|
||||
|
||||
# Run Gunicorn server with your Django application
|
||||
CMD ["gunicorn", "BH.wsgi:application"]
|
||||
|
|
@ -7,7 +7,7 @@ from django.utils import timezone
|
|||
class Blog(models.Model):
|
||||
content = models.TextField()
|
||||
title = models.CharField(max_length=150)
|
||||
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
author = models.TextField() #models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
date_posted = models.DateTimeField(default=timezone.now)
|
||||
|
||||
def get_absolute_url(self):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
services:
|
||||
django:
|
||||
build: .
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- .:/app
|
||||
ports:
|
||||
- "3030:3030"
|
||||
command: >
|
||||
sh -c "python manage.py makemigrations blog --noinput &&
|
||||
python manage.py migrate --noinput &&
|
||||
python manage.py collectstatic --noinput &&
|
||||
gunicorn BH.wsgi:application --bind 0.0.0.0:3030 --workers ${GUNICORN_WORKERS:-3}"
|
||||
BIN
requirements.txt
BIN
requirements.txt
Binary file not shown.
Loading…
Reference in New Issue