Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7fcfe95

Browse files
committed
Tidy up docker setup
1 parent0fe0199 commit7fcfe95

File tree

11 files changed

+51
-129
lines changed

11 files changed

+51
-129
lines changed

‎Dockerfile‎

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,26 @@ RUN npm run build
1111
# Stage 2 - Setup server
1212
FROM ubuntu:18.04
1313

14-
RUN apt-get update \
15-
&& DEBIAN_FRONTEND=noninteractive apt-get install -y \
14+
RUN apt-get update
15+
16+
RUN apt-get install -y software-properties-common curl
17+
RUN (cd /etc/apt/trusted.gpg.d/ && curl -O https://www.postgresql.org/media/keys/ACCC4CF8.asc)
18+
RUN echo"deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)"-pgdg main > /etc/apt/sources.list.d/pgdg.list
19+
RUN apt-get update
20+
21+
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
1622
python3.8-dev \
17-
unzip \
18-
nginx \
19-
curl \
2023
vim \
2124
python3.8-distutils \
22-
gcc
25+
gcc \
26+
postgresql-client-12 \
27+
libpq-dev
2328

2429
RUN ln -s /usr/bin/python3.8 /usr/local/bin/python
25-
RUN python --version
2630
RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
2731
RUN python get-pip.py
28-
RUN pip --version
2932
RUN pip install poetry
3033

31-
RUN apt-get install -y software-properties-common
32-
RUN (cd /etc/apt/trusted.gpg.d/ && curl -O https://www.postgresql.org/media/keys/ACCC4CF8.asc)
33-
RUN echo"deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)"-pgdg main > /etc/apt/sources.list.d/pgdg.list
34-
RUN apt-get update -y
35-
RUN apt-get install -y postgresql-client-12 libpq-dev
36-
37-
#RUN curl -s https://packagecloud.io/install/repositories/rabbitmq/rabbitmq-server/script.deb.sh | bash
38-
3934
WORKDIR /usr/src/app
4035
COPY poetry.lock pyproject.toml ./
4136
RUN poetry config virtualenvs.create false
@@ -46,8 +41,6 @@ COPY ./backend ./backend
4641
WORKDIR /usr/src/app/backend
4742
RUN ./manage.py collectstatic --noinput
4843

49-
COPY ./backend/nginx.conf /etc/nginx
50-
5144
EXPOSE 3000
5245

5346
CMD ["bash","./entrypoint.sh"]

‎backend/book/settings.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
GITHUB_TOKEN=os.environ.get('GITHUB_TOKEN')
3535

36-
SEPARATE_WORKER_PROCESS=os.environ.get('SEPARATE_WORKER_PROCESS','False')[0].upper()=='T'
37-
3836
ALLOWED_HOSTS= [
3937
'alexmojaki.pythonanywhere.com',
4038
os.environ.get('HEROKU_APP_NAME','')+'.herokuapp.com',

‎backend/entrypoint.sh‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
#!/usr/bin/env bash
2-
set -ex
32

4-
#nginx
3+
set -eux
54

65
# We probably don't want this to be automatic but it makes life a lot easier
76
# For setting up the cloud
87
python manage.py migrate
98
python manage.py init_db
109

11-
# Prevent outdated from making http requests
12-
echo'["0.2.0", "2099-01-01 00:00:00"]'> /tmp/outdated_cache_outdated
13-
echo'["0.8.3", "2099-01-01 00:00:00"]'> /tmp/outdated_cache_birdseye
10+
# If no MASTER_URL is set, start a server in this container,
11+
# which the web server will contact by default
12+
if [-z${MASTER_URL+x} ];then
13+
./master_server.sh&
14+
fi
1415

15-
gunicorn --bind 127.0.0.1:5000 main.workers.master:app --access-logfile - --error-log - --threads 10 --worker-class gthread&
16-
17-
gunicorn -c gunicorn_config.py book.wsgi:application --bind 0.0.0.0:${PORT:-3000}
16+
gunicorn -c gunicorn_config_web.py book.wsgi:application --bind 0.0.0.0:${PORT:-3000}

‎backend/gunicorn_config.py‎

Lines changed: 0 additions & 25 deletions
This file was deleted.

‎backend/gunicorn_config_web.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
worker_class='gevent'
2+
keepalive=60
3+
accesslog='-'
4+
errorlog='-'

‎backend/gunicorn_config_worker.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bind="0.0.0.0:5000"
2+
threads=10
3+
worker_class="gthread"
4+
accesslog='-'
5+
errorlog='-'

‎backend/main/simple_settings.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
send_default_pii=True
1313
)
1414

15-
CLOUDAMQP_URL=os.environ.get('CLOUDAMQP_URL')
1615
SEPARATE_WORKER_PROCESS=os.environ.get('SEPARATE_WORKER_PROCESS','False')[0].upper()=='T'
16+
17+
MASTER_URL=os.environ.get('MASTER_URL',"http://localhost:5000/")

‎backend/main/workers/master.py‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,6 @@ def run_server():
118118
app.run(host="0.0.0.0")
119119

120120

121-
master_url="http://localhost:5000/"
122-
123-
124121
@lru_cache()
125122
defmaster_session():
126123
importrequests
@@ -136,7 +133,7 @@ def master_session():
136133
# Wait until alive
137134
whileTrue:
138135
try:
139-
session.get(master_url+"health")
136+
session.get(simple_settings.MASTER_URL+"health")
140137
break
141138
exceptrequests.exceptions.ConnectionError:
142139
sleep(1)
@@ -146,7 +143,7 @@ def master_session():
146143

147144
defworker_result(entry):
148145
session=master_session()
149-
returnsession.post(master_url+"run",json=entry).json()
146+
returnsession.post(simple_settings.MASTER_URL+"run",json=entry).json()
150147

151148

152149
if__name__=='__main__':

‎backend/master_server.sh‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
set -eux
4+
5+
# Prevent outdated from making http requests
6+
echo'["0.2.0", "2099-01-01 00:00:00"]'>/tmp/outdated_cache_outdated
7+
echo'["0.8.3", "2099-01-01 00:00:00"]'>/tmp/outdated_cache_birdseye
8+
9+
gunicorn -c gunicorn_config_worker.py main.workers.master:app

‎backend/nginx.conf‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp