Skip to content

Commit c1f82ed

Browse files
committed
Dockerziation initial commit
1 parent cfe9caa commit c1f82ed

File tree

8 files changed

+105
-7
lines changed

8 files changed

+105
-7
lines changed

.dockerignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules
2+
client/node_modules
3+
.dockerignore
4+
Dockerfile
5+
npm-debug.log
6+
.git
7+
.hg
8+
.svn

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ tests/geo/*.xlsx
2929
*.pid
3030
dump.rdb
3131
config.py
32+
client/package-lock.json

Dockerfile

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
FROM continuumio/anaconda3:latest
2+
3+
RUN groupadd -g 999 appuser && \
4+
useradd -m -r -u 999 -g appuser appuser
5+
6+
ADD . /app
7+
WORKDIR /app
8+
9+
RUN python3 -m ensurepip
10+
11+
# Prevent nginx from starting automatically
12+
RUN ln -s /dev/null /etc/systemd/system/nginx.service
13+
14+
RUN apt-get update -y
15+
RUN apt-get install -y apt-utils redis-server supervisor nginx libpq-dev gcc g++ make build-essential
16+
17+
RUN curl -sL https://deb.nodesource.com/setup_9.x | bash
18+
RUN apt-get install -yqq nodejs
19+
RUN apt-get clean -y
20+
21+
# RUN python3 -m pip install celery==4.2.2 # Because Celery 4.3 is broken
22+
RUN pip install -r server/localrequirements.txt
23+
RUN python3 setup.py develop
24+
25+
RUN echo "daemon off;" >> /etc/nginx/nginx.conf
26+
RUN rm -f /etc/nginx/conf.d/*
27+
RUN rm -f /etc/nginx/sites-enabled/*
28+
COPY build/nginx.conf /etc/nginx/conf.d/nginx.conf
29+
30+
RUN rm -rf client/node_modules
31+
RUN npm install -g bower
32+
RUN npm install -g gulp
33+
34+
COPY server/config.example.py server/config.py
35+
RUN ./bin/build_client.sh
36+
37+
EXPOSE 80 443
38+
39+
RUN chown -R appuser:appuser .
40+
CMD supervisord

bin/build_client.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ fi
4141
if [ -d "source/vendor" ]; then
4242
if [ -d "node_modules/bower/bin" ]; then
4343
echo -e '\nPruning bower modules...'
44-
node_modules/bower/bin/bower prune
44+
node_modules/bower/bin/bower prune --allow-root
4545
fi
4646
fi
4747

4848
# install npm and bower deps
4949
echo -e '\nInstalling npm dependencies...'
5050
npm install --skip-installed
51+
node_modules/bower/bin/bower install --allow-root
5152

5253
# compile sass scripts and minify javascript and copy client and everything
5354
echo -e '\nCompiling client (including minifying JavaScript)...'

client/package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"bower": "=1.5.3",
1111
"csswring": "=4.0.0",
1212
"event-stream": "=3.3.1",
13-
"gulp": "=3.9.0",
1413
"gulp-concat": "=2.6.0",
1514
"gulp-css-globbing": "=0.1.8",
1615
"gulp-livereload": "=3.8.1",
@@ -21,16 +20,13 @@
2120
"gulp-regex-replace": "^0.2.3",
2221
"gulp-replace": "^0.5.4",
2322
"gulp-requirejs": "=0.1.3",
24-
"gulp-sass": "=2.0.4",
23+
"gulp-sass": "^4.0.0",
2524
"gulp-uglify": "=1.4.1",
2625
"gulp-util": "=3.0.6",
2726
"postcss-assets": "=3.0.3",
2827
"postcss-import": "=7.0.0",
2928
"underscore": "=1.8.3"
3029
},
31-
"scripts": {
32-
"postinstall": "bower install"
33-
},
3430
"dependencies": {
3531
"gulp": "^3.9.1"
3632
}

client/source/sass/main/project/_cost-coverage.scss

+2
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@
8787
margin-right: 40px;
8888
}
8989

90+
/* FIXME
9091
&.invalid {
9192
border: solid #FF0000 1px;
9293
outline: 0px;
9394
}
95+
*/
9496

9597
.c-caption {
9698
text-align: center;

server/config.example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import multiprocessing
55
import math
66

7-
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI','postgresql+psycopg2://optima:optima@localhost:5432/optima')
7+
SQLALCHEMY_DATABASE_URI = os.getenv('SQLALCHEMY_DATABASE_URI','postgresql+psycopg2://optima:optima@vladh.net:5432/optima')
88
SECRET_KEY = os.getenv('SECRET_KEY','F12Zr47j\3yX R~X@H!jmM]Lwf/,?KT')
99
UPLOAD_FOLDER = os.getenv('UPLOAD_FOLDER','/tmp/uploads')
1010
REDIS_URL = os.getenv('REDIS_URL', 'redis://127.0.0.1:6379/4') # Shortcut for setting both the celery broker and result backend cache

supervisord.conf

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[supervisord]
2+
nodaemon=true
3+
4+
[program:celery]
5+
command=celery -A server.webapp.tasks.celery_instance worker -l info
6+
stdout_logfile=/dev/stdout
7+
stdout_logfile_maxbytes=0
8+
stdout_logfile=/dev/stderr
9+
stdout_logfile_maxbytes=0
10+
user=appuser
11+
autostart=true
12+
autorestart=true
13+
startsecs=10
14+
stopwaitsecs=600
15+
killasgroup=true
16+
priority=500
17+
18+
[program:app]
19+
command=python -m server._twisted_wsgi 8080
20+
stdout_logfile=nutrition_stdout.log
21+
stdout_logfile_maxbytes=0
22+
stdout_logfile=nutrition_stderr.log
23+
stdout_logfile_maxbytes=0
24+
user=appuser
25+
autostart=true
26+
autorestart=true
27+
startsecs=10
28+
stopwaitsecs=600
29+
30+
[program:nginx]
31+
command=/usr/sbin/nginx
32+
stdout_logfile=/dev/stdout
33+
stdout_logfile_maxbytes=0
34+
stderr_logfile=/dev/stderr
35+
stderr_logfile_maxbytes=0
36+
autostart=true
37+
autorestart=true
38+
startsecs=10
39+
stopwaitsecs=600
40+
41+
[program:redis]
42+
command=redis-server
43+
stdout_logfile=/dev/stdout
44+
stdout_logfile_maxbytes=0
45+
stderr_logfile=/dev/stderr
46+
stderr_logfile_maxbytes=0
47+
autostart=true
48+
autorestart=true
49+
startsecs=10
50+
stopwaitsecs=600

0 commit comments

Comments
 (0)