Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .container/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Timezone
TIMEZONE=America/Havana

# Python
PYTHON_VERSION=3.7

# Public domain
APP_DOMAIN=covid19cubadata.cu

# Point to the path of your applications code on your host
APP_CODE_PATH_HOST=../

# Point to where the `APP_CODE_PATH_HOST` should be in the container
APP_CODE_PATH_CONTAINER=/var/www/html

### Docker Host IP ########################################

# Enter your Docker Host IP (will be appended to /etc/hosts). Default is `10.0.75.1`
# But you can Or you can run the following command:
# docker exec -it covid19cubadata /bin/bash -c "hostname -i"
# If after the previous command execution the result is: 172.18.0.2
# Your Docker Host IP is ###.###.###.1 in the last octect, so it should be: 172.18.0.1
DOCKER_HOST_IP=10.0.75.1

### NGINX #################################################

NGINX_HOST_HTTP_PORT=80
#NGINX_HOST_HTTPS_PORT=443
NGINX_HOST_LOG_PATH=../logs/nginx/
NGINX_SITES_PATH=./nginx/sites/
NGINX_SSL_PATH=./nginx/ssl/
35 changes: 35 additions & 0 deletions .container/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.3"

services:
covid19cubadata_web:
image: covid19cubadata/web:latest
build:
context: ./nginx
args:
- TZ=${TIMEZONE}
- http_proxy
- https_proxy
- no_proxy
container_name: covid19cubadata
volumes:
- ${APP_CODE_PATH_HOST}:${APP_CODE_PATH_CONTAINER}
- ${NGINX_HOST_LOG_PATH}:/var/log/nginx
- ${NGINX_SITES_PATH}:/etc/nginx/sites-available
- ${NGINX_SSL_PATH}:/etc/nginx/ssl
extra_hosts:
- "host.docker.internal:${DOCKER_HOST_IP}"
- "${APP_DOMAIN}:${DOCKER_HOST_IP}"
ports:
- "${NGINX_HOST_HTTP_PORT}:80"
# - "${NGINX_HOST_HTTPS_PORT}:443"

covid19cubadata_update_countries:
image: covid19cubadata/update_countries:latest
build:
context: ..
dockerfile: .container/python/Dockerfile
args:
- PYTHON_VERSION=${PYTHON_VERSION}
- TZ=${TIMEZONE}
volumes:
- ${APP_CODE_PATH_HOST}/data:/app/src/data
37 changes: 37 additions & 0 deletions .container/nginx/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FROM nginx:alpine

COPY nginx.conf /etc/nginx/

###########################################################################
# Set Timezone
###########################################################################

ARG TZ=UTC
ENV TZ ${TZ}

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apk update \
&& apk upgrade \
&& apk --update add logrotate \
&& apk add --no-cache openssl \
&& apk add --no-cache bash

RUN set -x ; \
addgroup -g 82 -S www-data ; \
adduser -u 82 -D -S -G www-data www-data && exit 0 ; exit 1

# Create 'messages' file used from 'logrotate'
RUN touch /var/log/messages

# Copy 'logrotate' config file
COPY logrotate/nginx /etc/logrotate.d/

# Set upstream conf and remove the default conf
RUN rm /etc/nginx/conf.d/default.conf

ADD ./startup.sh /opt/startup.sh
RUN sed -i 's/\r//g' /opt/startup.sh
CMD ["/bin/bash", "/opt/startup.sh"]

EXPOSE 80 443
14 changes: 14 additions & 0 deletions .container/nginx/logrotate/nginx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/var/log/nginx/*.log {
daily
missingok
rotate 32
compress
delaycompress
nodateext
notifempty
create 644 www-data root
sharedscripts
postrotate
[ -f /var/run/nginx.pid ] && kill -USR1 `cat /var/run/nginx.pid`
endscript
}
34 changes: 34 additions & 0 deletions .container/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
user www-data;
worker_processes 4;
pid /run/nginx.pid;
daemon off;

events {
worker_connections 2048;
multi_accept on;
use epoll;
}

http {
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
client_max_body_size 20M;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
error_log /dev/stderr;
gzip on;
gzip_disable "msie6";

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS';

include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-available/*.conf;
open_file_cache off; # Disabled for issue 619
charset UTF-8;
}
53 changes: 53 additions & 0 deletions .container/nginx/sites/covid19cubadata.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
server {

listen 80;
listen [::]:80;

# For https
# listen 443 ssl;
# listen [::]:443 ssl ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;

server_name _;

root /var/www/html;
index index.php index.html index.htm;

location ~* .(ico|gif|jpg|jpeg|png|htm|html|js|css|ttf|otf|woff|woff2|eot|svg|svgz|pdf|doc|xls|ppt|rtf|tar|zip|tgz|gz|rar|bz2|wmv|avi|mpg|mpeg|mp4|mp3|swf|flv|exe|mid|midi|wav|bmp)$ {
gzip on;
gzip_static on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.0;
gzip_types
text/plain
text/css
text/js
text/xml
text/x-component
text/javascript
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
image/svg+xml;
expires max;
}

location ~ /\.ht {
deny all;
}

# For https
# location /.well-known/acme-challenge/ {
# root /var/www/letsencrypt/;
# log_not_found off;
# }

error_log /var/log/nginx/covid19cubadata.local_error.log;
access_log /var/log/nginx/covid19cubadata.local_access.log;
}
4 changes: 4 additions & 0 deletions .container/nginx/ssl/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.crt
*.csr
*.key
*.pem
13 changes: 13 additions & 0 deletions .container/nginx/startup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ ! -f /etc/nginx/ssl/default.crt ]; then
openssl genrsa -out "/etc/nginx/ssl/default.key" 2048
openssl req -new -key "/etc/nginx/ssl/default.key" -out "/etc/nginx/ssl/default.csr" -subj "/CN=default/O=default/C=UK"
openssl x509 -req -days 365 -in "/etc/nginx/ssl/default.csr" -signkey "/etc/nginx/ssl/default.key" -out "/etc/nginx/ssl/default.crt"
fi

# Start crond in background
crond -l 2 -b

# Start nginx in foreground
nginx
53 changes: 53 additions & 0 deletions .container/python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
ARG PYTHON_VERSION

FROM python:${PYTHON_VERSION}

ENV PYTHONUNBUFFERED 1
ENV PYTHONOPTIMIZE 1

ENV APP_HOME /app
ENV SRC_HOME $APP_HOME/src
ENV VENV_HOME $APP_HOME/venv

ENV APP_USER covid19cubadata
ENV APP_USER_UID 1000
ENV APP_GROUP covid19cubadata
ENV APP_GROUP_GID 1000


RUN set -eux; \
echo 'deb http://host.docker.internal:8081/repository/debian-buster buster main' > /etc/apt/sources.list; \
echo 'deb http://host.docker.internal:8081/repository/debian-buster-security buster/updates main' >> /etc/apt/sources.list; \
echo 'deb http://host.docker.internal:8081/repository/debian-buster-updates buster-updates main' >> /etc/apt/sources.list;

RUN set -eux; \
apt-get -qq update; \
apt-get -qqy install \
apt-utils \
python-virtualenv \
build-essential; \
rm -rf /var/lib/apt/lists/*;

ARG TZ=UTC
ENV TZ ${TZ}

RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
echo $TZ > /etc/timezone && \
dpkg-reconfigure -f noninteractive tzdata && \
mkdir /tz && cp /etc/timezone /tz/ && cp /etc/localtime /tz/

RUN groupadd -r -g $APP_GROUP_GID $APP_GROUP && useradd -r -u $APP_USER_UID -d $APP_HOME -g $APP_GROUP $APP_USER
RUN mkdir -p $SRC_HOME && mkdir -p $VENV_HOME
RUN chown -R $APP_USER:$APP_GROUP $SRC_HOME $VENV_HOME

WORKDIR $APP_HOME
RUN virtualenv -p python $VENV_HOME
COPY ./utils/requirements.txt $SRC_HOME
SHELL ["/bin/bash", "-c"]
RUN source $VENV_HOME/bin/activate && pip install -r $SRC_HOME/requirements.txt --index-url http://host.docker.internal:8081/repository/pypi/simple --trusted-host host.docker.internal
COPY ./.container/python/docker-entrypoint.sh /docker-entrypoint.sh
COPY ./utils/update_countries.py $SRC_HOME/update_countries.py
RUN chmod +x /docker-entrypoint.sh && chown $APP_USER:$APP_GROUP /docker-entrypoint.sh && chown $APP_USER:$APP_GROUP $SRC_HOME
USER $APP_USER

ENTRYPOINT ["/docker-entrypoint.sh"]
9 changes: 9 additions & 0 deletions .container/python/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
shopt -s extglob globstar

source $VENV_HOME/bin/activate
cd $SRC_HOME
python update_countries.py

exec "$@"
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# Created by .ignore support plugin (hsz.mobi)
/.idea/
/.idea/
logs/
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,44 @@
# covid19cubadata.github.io
Covid19 - Dashboard for Cuba


### How to run with Docker
*Use Docker First - Then Learn About It Later*

#### Requirements
* [Install Docker](https://docs.docker.com/get-docker/)
* [Install Docker Compose](https://docs.docker.com/compose/install/)


#### Compile and run

*From project root directory*

1. Build Docker images for web application and python script:
```
docker-compose -f .container/docker-compose.yml build
```

2. Run the Docker container for the web application
```
docker-compose -f .container/docker-compose.yml up -d covid19cubadata_web
```

3. Visit the website

Open a browser and write: `http://localhost`

or, you can add `covid19cubadata.cu` to your hosts files
```
127.0.0.1 covid19cubadata.cu
```
* on Windows system, you must edit `%SYSTEM%\drivers\etc\hosts`
* on Linux system, you must edit `/etc/hosts`

and finally visit: `http://covid19cubadata.cu`

4. Run the standalone Python script to update countries data
```
docker-compose -f .container/docker-compose.yml up covid19cubadata_update_countries
```

4 changes: 2 additions & 2 deletions casos.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<meta property="og:url" content="https://covid19cubadata.github.io/casos.html" />

<link rel="stylesheet" href="css/bootstrap.min.css" />
<link href="css/fontawesome-5.8.2/css/all.css" rel="stylesheet">
<link href="css/fontawesome-5.8.2/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="js/jui/jquery-ui.min.css" />
<link rel="stylesheet" href="js/datatables/dataTables.bootstrap4.min.css" />
<link rel="stylesheet" href="js/datatables/fixedHeader.bootstrap4.min.css" />
<link rel="stylesheet" href="js/datatables/responsive.bootstrap4.min.css" />
<link rel="stylesheet" href="css/custom.css" />
<link rel="stylesheet" href="css/custom.min.css" />
</head>

<body>
Expand Down
3 changes: 1 addition & 2 deletions css/c3.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
opacity: 0.5;
}


.filtertodo {
color: white;
background-color: #B1B1B1;
Expand All @@ -187,7 +186,7 @@
}

.big {
font-size: 30;
font-size: 30px;
}


1 change: 1 addition & 0 deletions css/c3.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -649,3 +649,7 @@ table.dataTable.table-external.dtr-inline.collapsed > tbody > tr[role="row"] > t
div.dataTables_wrapper div.dataTables_filter input {
width: 80% !important;
}

.ui-slider .ui-slider-handle {
z-index: 1;
}
Loading