Skip to content

Commit 1351881

Browse files
committed
🔧 dockerize the application
1 parent 2eed0d5 commit 1351881

File tree

5 files changed

+41
-1
lines changed

5 files changed

+41
-1
lines changed

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**/.DS_Store
2+
**/__pycache__
3+
**/db.sqlite3

Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM python:3
2+
3+
ENV PYTHONUNBUFFERED 1
4+
5+
WORKDIR /usr/src/app
6+
7+
COPY requirements.txt ./
8+
RUN pip install --no-cache-dir -r requirements.txt
9+
10+
COPY messages .
11+
12+
WORKDIR /usr/src/app
13+
14+
EXPOSE 8000
15+
16+
COPY entrypoint.sh .
17+
18+
ENTRYPOINT ["sh", "entrypoint.sh"]

docker-compose.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: '3'
2+
services:
3+
web:
4+
build:
5+
context: .
6+
dockerfile: Dockerfile
7+
image: messages-web-image
8+
container_name: messages-web-container
9+
ports:
10+
- "8000:8000"
11+
redis:
12+
image: redis
13+
container_name: messages-redis-container
14+
ports:
15+
- "6379:6379"

entrypoint.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
python manage.py migrate --no-input
4+
python manage.py runserver 0.0.0.0:8000

messages/messages/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
"default": {
145145
"BACKEND": "channels_redis.core.RedisChannelLayer",
146146
"CONFIG": {
147-
"hosts": [("127.0.0.1", 6379)],
147+
"hosts": [("redis", 6379)],
148148
},
149149
},
150150
}

0 commit comments

Comments
 (0)