diff --git a/Dockerfile b/Dockerfile index 3195a9f..a318f63 100644 --- a/Dockerfile +++ b/Dockerfile @@ -13,7 +13,7 @@ COPY requirements.txt /code/ RUN apt-get update && apt-get install -y gcc RUN pip install --upgrade pip -RUN pip install --default-timeout=10000 -r requirements.txt +RUN pip install -r requirements.txt # Copy project COPY . /code/ \ No newline at end of file diff --git a/docker-compose-deploy.yml b/docker-compose-deploy.yml new file mode 100644 index 0000000..a6cf5ad --- /dev/null +++ b/docker-compose-deploy.yml @@ -0,0 +1,32 @@ +version: '3.8' + +services: + brazil-blog-web: + container_name: brazil-blog + build: . + command: bash -c "python manage.py migrate && python manage.py bootstrap && python manage.py runserver 0.0.0.0:8000" + environment: + - DJANGO_SUPERUSER_USERNAME=${DJANGO_SUPERUSER_USERNAME} + - DJANGO_SUPERUSER_PASSWORD=${DJANGO_SUPERUSER_PASSWORD} + - DJANGO_SUPERUSER_EMAIL=${DJANGO_SUPERUSER_EMAIL} + volumes: + - ./src:/code + ports: + - 8000:8000 + + nginx: + image: nginx:latest + ports: + - "80:80" + volumes: + - ./nginx:/etc/nginx/conf.d + depends_on: + - brazil-blog-web + + redis: + image: redis:latest + ports: + - "6379:6379" + +volumes: + redis_data: \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 7a75685..5e4277c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,4 +12,9 @@ services: volumes: - ./src:/code ports: - - 8000:8000 \ No newline at end of file + - 8000:8000 + + redis: + image: redis:latest + ports: + - "6379:6379" \ No newline at end of file diff --git a/nginx/default.conf b/nginx/default.conf new file mode 100644 index 0000000..cf21f9a --- /dev/null +++ b/nginx/default.conf @@ -0,0 +1,11 @@ +server { + listen 80; + + location / { + proxy_pass http://brazil-blog-web:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/requirements.txt b/requirements.txt index 9362722..d967f54 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ Django wagtail>=6.0 -django-allauth \ No newline at end of file +django-allauth +django-redis \ No newline at end of file diff --git a/src/brazil_blog/settings/base.py b/src/brazil_blog/settings/base.py index 9caee5f..9d1bde8 100644 --- a/src/brazil_blog/settings/base.py +++ b/src/brazil_blog/settings/base.py @@ -169,6 +169,16 @@ }, } +CACHES = { + "default": { + "BACKEND": "django_redis.cache.RedisCache", + "LOCATION": "redis://redis:6379/1", + "OPTIONS": { + "CLIENT_CLASS": "django_redis.client.DefaultClient", + } + } +} + # Wagtail settings diff --git a/src/requirements.txt b/src/requirements.txt deleted file mode 100644 index 9adca01..0000000 --- a/src/requirements.txt +++ /dev/null @@ -1,3 +0,0 @@ -Django>=4.2,<5.1 -wagtail>=6.0,<6.1 -django-allauth \ No newline at end of file