Skip to content

Commit

Permalink
Added: Redis configuration & Preconfigure nginx already (#3)
Browse files Browse the repository at this point in the history
* Remove timeout parameter

* Add Redis service to docker-compose.yml and update requirements.txt

* Remove unused requirements.txt

* Add Docker Compose file for deployment and Nginx configuration
  • Loading branch information
drikusroor authored Apr 13, 2024
1 parent 13cace1 commit 9329eae
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
32 changes: 32 additions & 0 deletions docker-compose-deploy.yml
Original file line number Diff line number Diff line change
@@ -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:
7 changes: 6 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ services:
volumes:
- ./src:/code
ports:
- 8000:8000
- 8000:8000

redis:
image: redis:latest
ports:
- "6379:6379"
11 changes: 11 additions & 0 deletions nginx/default.conf
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Django
wagtail>=6.0
django-allauth
django-allauth
django-redis
10 changes: 10 additions & 0 deletions src/brazil_blog/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions src/requirements.txt

This file was deleted.

0 comments on commit 9329eae

Please sign in to comment.