File tree Expand file tree Collapse file tree 7 files changed +76
-8
lines changed Expand file tree Collapse file tree 7 files changed +76
-8
lines changed Original file line number Diff line number Diff line change @@ -6,10 +6,12 @@ WORKDIR /usr/src/app
6
6
7
7
RUN apk add --update --no-cache postgresql-client
8
8
RUN apk add --update --no-cache --virtual .tmp-build-deps \
9
- postgresql-dev gcc python3-dev musl-dev
9
+ postgresql-dev gcc python3-dev musl-dev linux-headers
10
10
11
11
COPY requirements.txt ./
12
- RUN pip install --no-cache-dir -r requirements.txt
12
+ COPY ./scripts /scripts
13
+
14
+ RUN pip install -r requirements.txt
13
15
14
16
RUN apk del .tmp-build-deps
15
17
@@ -18,14 +20,20 @@ RUN adduser --disabled-password app-user
18
20
RUN mkdir -p /usr/src/vol/web/static && \
19
21
mkdir -p /usr/src/vol/web/media && \
20
22
chown -R app-user:app-user /usr/src/vol && \
21
- chmod -R 755 /usr/src/vol
23
+ chmod -R 755 /usr/src/vol && \
24
+ chmod -R +x /scripts
22
25
23
- USER app-user
26
+ ENV PATH= "/scripts:$PATH"
24
27
25
28
COPY messages ./messages/
26
29
30
+ WORKDIR /usr/src/app/messages/
31
+
27
32
EXPOSE 8000
28
33
29
34
COPY entrypoint.sh .
35
+ RUN chmod +x entrypoint.sh
36
+
37
+ USER app-user
30
38
31
- ENTRYPOINT ["sh" , "entrypoint .sh" ]
39
+ CMD ["run .sh" ]
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+ services :
3
+ web :
4
+ build :
5
+ context : .
6
+ dockerfile : Dockerfile
7
+ restart : always
8
+ image : messages-web-image
9
+ container_name : messages-web-container
10
+ volumes :
11
+ - static-data:/usr/src/vol/web
12
+ environment :
13
+ - DEBUG=${DEBUG}
14
+ - DB_HOST=db
15
+ - DB_NAME=${DB_NAME}
16
+ - DB_USER=${DB_USER}
17
+ - DB_PASSWORD=${DB_PASSWORD}
18
+ - SECRET_KEY=${SECRET_KEY}
19
+ - ALLOWED_HOSTS=${ALLOWED_HOSTS}
20
+ depends_on :
21
+ - db
22
+ redis :
23
+ image : redis:7
24
+ restart : always
25
+ container_name : messages-redis-container
26
+ ports :
27
+ - 6379:6379
28
+ db :
29
+ image : postgres:15
30
+ restart : always
31
+ volumes :
32
+ - db_data:/var/lib/postgresql/data/
33
+ environment :
34
+ - POSTGRES_DB=${DB_NAME}
35
+ - POSTGRES_USER=${DB_USER}
36
+ - POSTGRES_PASSWORD=${DB_PASSWORD}
37
+ proxy :
38
+ build :
39
+ context : ./proxy
40
+ restart : always
41
+ depends_on :
42
+ - web
43
+ ports :
44
+ - 80:8000
45
+ volumes :
46
+ - static-data:/vol/static
47
+
48
+ volumes :
49
+ static-data :
50
+ db_data :
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ services:
4
4
build :
5
5
context : .
6
6
dockerfile : Dockerfile
7
+ entrypoint : ./entrypoint.sh
7
8
image : messages-web-image
8
9
container_name : messages-web-container
9
10
ports :
@@ -13,7 +14,6 @@ services:
13
14
- ./messages:/usr/src/app/messages
14
15
- ./data/web:/usr/src/vol/web
15
16
environment :
16
- - SECRET_KEY=this-is-a-dev-secret-key
17
17
- DEBUG=${DEBUG}
18
18
- DB_HOST=db
19
19
- DB_NAME=${DB_NAME}
Original file line number Diff line number Diff line change 1
- #! /bin/bash
1
+ #! /bin/sh
2
2
3
3
python messages/manage.py wait_for_db
4
4
python messages/manage.py migrate --no-input
Original file line number Diff line number Diff line change 2
2
listen ${LISTEN_PORT} ;
3
3
4
4
location /static {
5
- alias /usr/src/ vol/web /static;
5
+ alias /vol/static;
6
6
}
7
7
8
8
location / {
Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ toml==0.10.2
44
44
Twisted == 22.10.0
45
45
txaio == 22.2.1
46
46
typing_extensions == 4.4.0
47
+ uWSGI == 2.0.21
47
48
virtualenv == 20.16.6
48
49
wrapt == 1.14.1
49
50
zope.interface == 5.5.1
Original file line number Diff line number Diff line change
1
+ #! /bin/sh
2
+
3
+ set -e
4
+
5
+ python manage.py wait_for_db
6
+ python manage.py collectstatic --noinput
7
+ python manage.py migrate
8
+
9
+ uwsgi --socket :9000 --workers 4 --master --enable-threads --module messages.wsgi
You can’t perform that action at this time.
0 commit comments