Skip to content

Commit 45353f9

Browse files
Merge pull request #69 from TACC/sharrell-docker
Basic docker-compose integration
2 parents 9ffdb85 + 351f2ef commit 45353f9

21 files changed

+598
-130
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
services-conf/nginx.conf
12
dist/
23
rabbitmq-c/
34
tacc_stats.egg-info/
@@ -27,6 +28,7 @@ tacc_stats/version.py
2728
tacc_stats/cfg.py
2829
*egg*
2930
#*
31+
*.swp
3032
tacc_stats/taccstats
3133
Makefile.in
3234
/ar-lib
@@ -50,4 +52,4 @@ Makefile.in
5052
/stamp-h1
5153
/ltmain.sh
5254
/texinfo.tex
53-
tacc_stats/pickler/*lock
55+
tacc_stats/pickler/*lock

Dockerfile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# pull official base image
2+
FROM python:3.6.15
3+
4+
RUN useradd -ms /bin/bash hpcperfstats
5+
WORKDIR /home/hpcperfstats
6+
7+
# run as root
8+
RUN apt-get update && apt-get upgrade -y
9+
RUN apt-get install netcat supervisor -y
10+
11+
12+
ENV PYTHONDONTWRITEBYTECODE 1
13+
ENV PYTHONUNBUFFERED 1
14+
ENV PATH $PATH:/home/hpcperfstats/.local/bin
15+
16+
# install dependencies
17+
RUN pip install --upgrade pip
18+
COPY --chown=hpcperfstats:hpcperfstats ./requirements.txt .
19+
RUN pip install -r requirements.txt
20+
21+
22+
# copy project
23+
COPY --chown=hpcperfstats:hpcperfstats . .
24+
# This includes the tacc_stats.ini
25+
#COPY --chown=hpcperfstats:hpcperfstats ./tacc_stats.ini .
26+
27+
28+
RUN pip install .
29+
30+
ADD services-conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
31+

docker-compose.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
services:
2+
web:
3+
build: ./
4+
image: hpcperfstats
5+
command: /home/hpcperfstats/services-conf/django_startup.sh
6+
env_file:
7+
- ./.env.dev
8+
9+
pipeline:
10+
image: hpcperfstats
11+
depends_on:
12+
- web
13+
command: /home/hpcperfstats/services-conf/supervisor_startup.sh
14+
volumes:
15+
- hpcperfstatsdata:/hpcperfstats/
16+
env_file:
17+
- ./.env.dev
18+
19+
proxy:
20+
restart: always
21+
image: nginx:1-alpine
22+
ports:
23+
- 80:80
24+
- 443:443
25+
volumes:
26+
- ./services-conf/nginx.conf:/etc/nginx/conf.d/default.conf
27+
- /etc/letsencrypt/:/etc/letsencrypt/
28+
29+
db:
30+
image: timescale/timescaledb:latest-pg15
31+
volumes:
32+
- postgres_data:/var/lib/postgresql/data/
33+
environment:
34+
- POSTGRES_USER=hpcperfstats
35+
- POSTGRES_PASSWORD=hpcperfstats
36+
37+
rabbitmq:
38+
image: rabbitmq:4-alpine
39+
ports:
40+
- 5672:5672
41+
# Admin Console
42+
# - 15672:15672
43+
volumes:
44+
- rabbitmq_messages:/var/lib/rabbitmq/
45+
- /var/log/rabbitmq:/var/log/rabbitmq
46+
47+
networks:
48+
default:
49+
driver: bridge
50+
51+
volumes:
52+
postgres_data:
53+
54+
rabbitmq_messages:
55+
56+
hpcperfstatsdata:
57+
driver: local
58+
driver_opts:
59+
type: none
60+
device: /home/sharrell/compose_test/hpcperfstats_data/
61+
o: bind

docker-instructions.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# From a base rocky image
2+
3+
dnf install docker git podman-compose
4+
5+
# May need to use an ssh git address if you plan to commit to the repo
6+
git clone https://github.com/TACC/tacc_stats.git
7+
8+
cd tacc_stats
9+
10+
git checkout sharrell-docker
11+
12+
# Create env.dev file, contents:
13+
DEBUG=1
14+
SECRET_KEY=foo
15+
PATH=$PATH:/home/hpcperfstats/.local/bin
16+
# end contents
17+
18+
# In service-conf, nginx.conf needs to be chosen, to make things easier for development, use the nossl config, if its production use the ssl version, you can copy the nginx-nossl.conf to nginx.conf and build.
19+
20+
cp services-conf/nginx-nossl.conf services-conf/nginx.conf
21+
22+
docker compose up --build -d
23+
24+
# to see the startup
25+
docker compose logs
26+
27+
#you should be able to get to the website at this point, will error if no data
28+
29+
30+
31+
32+

requirements.txt

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
agavepy==0.9.5
2+
ansible-cmdb==1.31
3+
asgiref==3.4.1
4+
attrs==21.2.0
5+
backports.ssl-match-hostname==3.7.0.1
6+
bokeh==2.3.3
7+
certifi==2021.10.8
8+
cffi==1.15.1
9+
charset-normalizer==2.0.9
10+
cheroot==8.5.2
11+
CherryPy==18.6.1
12+
cloudpickle==2.0.0
13+
configparser==5.2.0
14+
cryptography==40.0.2
15+
cycler==0.11.0
16+
Django==3.1.14
17+
future==0.18.2
18+
gitdb==4.0.9
19+
GitPython==3.1.20
20+
idna==3.3
21+
importlib-metadata==4.8.2
22+
importlib-resources==5.4.0
23+
iniconfig==1.1.1
24+
jaraco.classes==3.2.1
25+
jaraco.collections==3.4.0
26+
jaraco.functools==3.4.0
27+
jaraco.text==3.6.0
28+
Jinja2==3.0.3
29+
jsonxs==0.6
30+
kiwisolver==1.3.1
31+
Mako==1.1.6
32+
MarkupSafe==2.0.1
33+
matplotlib==3.3.4
34+
more-itertools==8.12.0
35+
mysql==0.0.3
36+
mysql-connector-python==8.0.33
37+
mysqlclient==2.1.1
38+
numpy==1.19.5
39+
packaging==21.3
40+
pandas==1.1.5
41+
pgcopy==1.5.0
42+
pika==1.2.0
43+
Pillow==8.4.0
44+
pip==21.3.1
45+
pluggy==1.0.0
46+
portend==3.0.0
47+
protobuf==3.19.1
48+
psycopg2==2.9.2
49+
psycopg2-binary==2.9.2
50+
py==1.11.0
51+
pycparser==2.21
52+
PyMySQL==1.0.2
53+
pyparsing==3.0.6
54+
pytest==6.2.5
55+
python-dateutil==2.8.2
56+
python-hostlist==1.21
57+
python-memcached==1.59
58+
pytz==2021.3
59+
PyYAML==6.0
60+
requests==2.26.0
61+
requests-toolbelt==0.9.1
62+
setuptools==39.2.0
63+
six==1.16.0
64+
smmap==5.0.0
65+
sqlparse==0.4.2
66+
tempora==4.1.2
67+
termcolor==1.1.0
68+
toml==0.10.2
69+
tornado==6.1
70+
typing==3.7.4.3
71+
typing_extensions==4.0.1
72+
urllib3==1.26.7
73+
ushlex==0.99.1
74+
websocket-client==0.53.0
75+
zc.lockfile==2.0
76+
zipp==3.6.0
77+
gunicorn

services-conf/django_startup.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/sh
2+
3+
echo "Waiting for postgres..."
4+
5+
while ! nc -z db 5432; do
6+
sleep 0.1
7+
done
8+
9+
echo "PostgreSQL started"
10+
11+
# detect if the tables are existing and create if not
12+
/usr/local/bin/python3 tacc_stats/site/manage.py makemigrations
13+
/usr/local/bin/python3 tacc_stats/site/manage.py migrate
14+
15+
# then run this (gunicorn later)
16+
/usr/local/bin/gunicorn tacc_stats.site.tacc_stats_site.wsgi --bind 0.0.0.0:8000 --env DJANGO_SETTINGS_MODULE=tacc_stats.site.tacc_stats_site.settings -u hpcperfstats
17+

services-conf/nginx-nossl.conf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
upstream tacc_stats {
2+
server web:8000;
3+
}
4+
5+
6+
server {
7+
listen 80;
8+
9+
client_max_body_size 14M;
10+
location / {
11+
proxy_pass http://web:8000;
12+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
13+
proxy_set_header Host $host;
14+
proxy_redirect off;
15+
}
16+
}
17+

services-conf/nginx-withssl.conf

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
upstream django_server {
2+
server web:8000;
3+
}
4+
5+
6+
server {
7+
listen 80;
8+
location / {
9+
rewrite ^ https://$host$request_uri? permanent;
10+
}
11+
}
12+
13+
server {
14+
listen 443 ssl;
15+
16+
ssl_certificate /etc/letsencrypt/live/stats.stampede3.tacc.utexas.edu/fullchain.pem;
17+
ssl_certificate_key /etc/letsencrypt/live/stats.stampede3.tacc.utexas.edu/privkey.pem;
18+
19+
location / {
20+
proxy_pass http://web:8000;
21+
proxy_redirect off;
22+
proxy_http_version 1.1;
23+
proxy_cache_bypass $http_upgrade;
24+
proxy_set_header Upgrade $http_upgrade;
25+
proxy_set_header Connection keep-alive;
26+
proxy_set_header Host $host;
27+
proxy_set_header X-Real-IP $remote_addr;
28+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
29+
proxy_set_header X-Forwarded-Proto $scheme;
30+
proxy_set_header X-Forwarded-Host nginx;
31+
proxy_buffer_size 128k;
32+
proxy_buffers 4 256k;
33+
proxy_busy_buffers_size 256k;
34+
}
35+
}

services-conf/supervisor_startup.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/sh
2+
3+
4+
chmod -c 755 /hpcperfstats/
5+
# make directories if they are not there
6+
mkdir -pv /hpcperfstats/accounting
7+
mkdir -pv /hpcperfstats/archive
8+
mkdir -pv /hpcperfstats/daily_archive
9+
mkdir -pv /hpcperfstats/logs
10+
chown -R hpcperfstats:hpcperfstats /hpcperfstats/*
11+
12+
/usr/bin/supervisord
13+
14+
15+

services-conf/supervisord.conf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[supervisord]
2+
nodaemon=true
3+
logfile=/dev/fd/1
4+
logfile_maxbytes=0
5+
6+
[program:hpcperfstats-rabbitmq-listener]
7+
command=/usr/local/bin/python3 /home/hpcperfstats/tacc_stats/listend.py
8+
user=hpcperfstats
9+
autorestart=true
10+
startretries=20
11+
stdout_redirect=true
12+
stdout_logfile=/dev/fd/1
13+
stdout_logfile_maxbytes=0
14+
stderr_redirect=true
15+
stderr_logfile=/dev/fd/1
16+
stderr_logfile_maxbytes=0
17+
18+
19+
[program:sync_acct]
20+
command=/usr/local/bin/python3 /home/hpcperfstats/tacc_stats/dbload/sync_acct.py
21+
user=hpcperfstats
22+
autorestart=true
23+
startretries=20
24+
stdout_redirect=true
25+
stdout_logfile=/dev/fd/1
26+
stdout_logfile_maxbytes=0
27+
stderr_redirect=true
28+
stderr_logfile=/dev/fd/1
29+
stderr_logfile_maxbytes=0
30+

0 commit comments

Comments
 (0)