-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
420 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
FROM python:2.7 | ||
MAINTAINER Federico Gonzalez | ||
|
||
# Update debian packages | ||
RUN DEBIAN_FRONTEND=noninteractive | ||
RUN apt-get update | ||
RUN apt-get upgrade -y | ||
|
||
# Install debian dependencies | ||
RUN apt-get --force-yes install -y wget curl locales git nano htop build-essential nginx | ||
RUN apt-get --force-yes install -y nodejs nodejs-legacy | ||
RUN apt-get --force-yes install -y binutils libproj-dev gdal-bin libgeoip1 python-gdal | ||
RUN apt-get --force-yes install -y libjpeg-dev libpng3 libpng12-dev libfreetype6-dev zlib1g-dev | ||
RUN apt-get --force-yes install -y jpegoptim optipng | ||
RUN apt-get --force-yes install -y libffi-dev libxml2-dev libxslt1-dev | ||
|
||
# Install npm | ||
RUN curl -sL https://deb.nodesource.com/setup_4.x | bash - | ||
RUN wget http://npmjs.org/install.sh | ||
RUN sh install.sh | ||
|
||
# Configure npm | ||
RUN npm config set registry http://registry.npmjs.org | ||
RUN git config --global url."https://".insteadOf git:// | ||
|
||
# Install bower and gulp | ||
RUN npm install -g bower | ||
|
||
# Download source | ||
RUN cd /var/www/ && git clone https://github.com/gnutn/eventoL.git eventol | ||
|
||
# Install python dependencies | ||
RUN cd /var/www/eventol/ && virtualenv venv | ||
RUN cd /var/www/eventol/ && . venv/bin/activate && pip install -r requirements.txt | ||
|
||
# Install npm and bower dependencies | ||
RUN cd /var/www/eventol/ && bower install --allow-root | ||
|
||
# Compile less files | ||
RUN npm install -g less | ||
RUN lessc /var/www/eventol/manager/static/manager/less/flisol.less > /var/www/eventol/manager/static/manager/css/flisol.css | ||
RUN lessc /var/www/eventol/manager/static/manager/less/flisol-bootstrap.less > /var/www/eventol/manager/static/manager/css/flisol-bootstrap.css | ||
|
||
# Configure source | ||
RUN chmod +x /var/www/eventol/manage.py | ||
|
||
# Install supervisord and gunicorn | ||
RUN cd /var/www/eventol/ && . venv/bin/activate && pip install supervisor | ||
RUN cd /var/www/eventol/ && . venv/bin/activate && pip install gunicorn | ||
ADD supervisor/supervisord.conf /etc/supervisord.conf | ||
ADD gunicorn/gunicorn-eventol.sh /var/www/eventol/gunicorn-eventol.sh | ||
RUN chmod +x /var/www/eventol/gunicorn-eventol.sh | ||
|
||
# Configure nginx | ||
RUN rm -rf /etc/nginx/sites-enabled/* | ||
RUN rm -rf /etc/nginx/sites-available/* | ||
RUN rm -rf /etc/nginx/conf.d/default.conf | ||
ADD nginx/nginx.conf /etc/nginx/nginx.conf | ||
ADD nginx/eventol.conf /etc/nginx/sites-available/eventol.conf | ||
RUN ln -s /etc/nginx/sites-available/eventol.conf /etc/nginx/sites-enabled/eventol.conf | ||
|
||
# Add run script | ||
RUN mkdir /var/www/eventol/log | ||
ADD script/run.sh /run.sh | ||
RUN chmod +x /run.sh | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["/run.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Proceso | ||
======= | ||
|
||
```bash | ||
docker build -t eventol . | ||
docker run --name eventol-postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=eventol -e POSTGRES_DB=eventol -p 5432:5432 -d postgres | ||
docker run -d -i --name="eventol" --hostname="eventol" -p 8000:8000 --link=eventol-postgres -e PSQL_HOST=eventol-postgres -t eventol:latest | ||
``` | ||
|
||
Listo | ||
----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
eventol: | ||
build: . | ||
ports: | ||
- 8000:8000 | ||
links: | ||
- postgres | ||
volumes: | ||
- ./vol/logs:/var/www/eventol/log | ||
- ./vol/gunicorn:/var/www/eventol/gunicorn | ||
command: /run.sh | ||
restart: always | ||
envirotment: | ||
- PSQL_HOST=postgres | ||
postgres: | ||
restart: always | ||
image: postgres:9.5 | ||
environment: | ||
- POSTGRES_PASSWORD=secret | ||
- POSTGRES_USER=eventol | ||
- POSTGRES_DB=eventol | ||
volumes_from: | ||
- data | ||
data: | ||
image: postgres:9.5 | ||
volumes: | ||
- /var/lib/postgresql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
NAME="eventol" # Name of the application | ||
DJANGODIR=/var/www/eventol/ # Django project directory | ||
SOCKFILE=/var/www/eventol/gunicorn/gunicorn.sock # we will communicate using this unix socket | ||
USER=root # the user to run as | ||
GROUP=root # the group to run as | ||
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | ||
DJANGO_SETTINGS_MODULE=eventoL.settings # which settings file should Django use | ||
DJANGO_WSGI_MODULE=eventoL.wsgi # WSGI module name | ||
|
||
# Activate the virtual environment | ||
cd ${DJANGODIR} | ||
export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE} | ||
export PYTHONPATH=$DJANGODIR:$PYTHONPATH | ||
|
||
# Create the run directory if it doesn't exist | ||
RUNDIR=$(dirname ${SOCKFILE}) | ||
test -d ${RUNDIR} || mkdir -p ${RUNDIR} | ||
|
||
# Start your Django Unicorn | ||
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) | ||
source /var/www/eventol/venv/bin/activate | ||
exec gunicorn ${DJANGO_WSGI_MODULE}:application \ | ||
--name ${NAME} \ | ||
--workers ${NUM_WORKERS} \ | ||
--user=${USER} \ | ||
--group=${GROUP} \ | ||
--bind=unix:${SOCKFILE} \ | ||
--log-level=debug \ | ||
--timeout=300 \ | ||
--log-file=/var/www/eventol/log/gunicorn.log \ | ||
--reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
upstream eventol_server { | ||
server unix:/var/www/eventol/gunicorn/gunicorn.sock fail_timeout=0; | ||
} | ||
|
||
server { | ||
listen 8000; | ||
server_name eventol; | ||
client_max_body_size 4G; | ||
|
||
access_log /var/www/eventol/log/nginx-access.log; | ||
error_log /var/www/eventol/log/nginx-error.log; | ||
|
||
location /static/ { | ||
alias /var/www/eventol/manager/static/; | ||
} | ||
|
||
location / { | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header Host $http_host; | ||
proxy_redirect off; | ||
proxy_read_timeout 300; | ||
|
||
if (!-f $request_filename) { | ||
proxy_pass http://eventol_server; | ||
break; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
worker_rlimit_nofile 200000; | ||
|
||
error_log /var/log/nginx/error.log warn; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 65535; | ||
multi_accept on; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
include /etc/nginx/conf.d/*.conf; | ||
include /etc/nginx/sites-enabled/*; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
cd /var/www/eventol/ | ||
source venv/bin/activate | ||
python manage.py migrate --noinput | ||
python manage.py makemigrations manager --noinput | ||
python manage.py migrate --noinput | ||
python manage.py syncdb --noinput | ||
python manage.py collectstatic --noinput | ||
python manage.py loaddata manager/initial_data/attendee_data.json | ||
python manage.py loaddata manager/initial_data/email_addresses.json | ||
python manage.py loaddata manager/initial_data/initial_data.json | ||
supervisord -u root -c /etc/supervisord.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[supervisord] | ||
nodaemon=true | ||
|
||
[program:eventol] | ||
directory=/var/www/eventol/ | ||
command=/var/www/eventol/gunicorn-eventol.sh | ||
autostart=true | ||
autorestart=true | ||
|
||
[program:nginx] | ||
command=nginx -g "daemon off;" | ||
autostart=true | ||
autorestart=true | ||
stdout_events_enabled=true | ||
stderr_events_enabled=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
## Deploy de EventoL | ||
|
||
Para un mejor y mas rápido deploy a producción, **EventoL** es configurable mediante variables de entorno para que durante el deploy el codigo no se tenga que modificar. | ||
|
||
### Variables de entorno de **EventoL** | ||
|
||
#### Django: | ||
|
||
- DJANGO_DEBUG (Default: **False**) | ||
- DJANGO_TEMPLATE_DEBUG (Default: **False**) | ||
- DJANGO_EMAIL_HOST (Default: **smtp.unset**) | ||
- DJANGO_EMAIL_PORT (Default: **587**) | ||
- DJANGO_EMAIL_HOST_USER (Default: **change_unset@mail.com**) | ||
- DJANGO_EMAIL_HOST_PASSWORD (Default: **secret**) | ||
- DJANGO_EMAIL_USE_TLS (Default: **True**) | ||
- DJANGO_EMAIL_FROM (Default: **change_unset@mail.com**) | ||
- DJANGO_ADMIN_TITLE (Default: **EventoL**) | ||
- DJANGO_SECRET_KEY (Default: **!a44%)(r2!1wp89@ds(tqzpo#f0qgfxomik)a$16v5v@b%)ecu**) | ||
|
||
#### Postgres: | ||
- PSQL_NAME (Default: **eventol**) | ||
- PSQL_USER (Default: **eventol**) | ||
- PSQL_PASSWORD (Default: **secret**) | ||
- PSQL_HOST (Default: **localhost**) | ||
- PSQL_PORT (Default: **5432**) | ||
|
||
#### Openshift: | ||
- OPENSHIFT_REPO_DIR configura las variables STATIC_ROOT y MEDIA_ROOT | ||
- OPENSHIFT_SECRET_TOKEN configura la varible DJANGO_SECRET_KEY | ||
- OPENSHIFT_APP_NAME configura la varible PSQL_NAME | ||
- OPENSHIFT_POSTGRESQL_DB_USERNAME configura la varible PSQL_USER | ||
- OPENSHIFT_POSTGRESQL_DB_PASSWORD configura la varible PSQL_PASSWORD | ||
- OPENSHIFT_POSTGRESQL_DB_HOST configura la varible PSQL_HOST | ||
- OPENSHIFT_POSTGRESQL_DB_PORT configura la varible PSQL_PORT | ||
- OPENSHIFT_APP_DNS configura la varible ALLOWED_HOSTS | ||
- OPENSHIFT_DATA_DIR | ||
|
||
#### Otras configuraciones para mail: | ||
- EVENTOL_EMAIL_BACKEND | ||
- EVENTOL_MAILGUN_ACCESS_KEY | ||
- EVENTOL_MAILGUN_SERVER_NAME | ||
|
||
### Deploy con Docker | ||
```bash | ||
cd deploy/docker | ||
docker build -t eventol . | ||
docker run --name eventol-postgres -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=eventol -e POSTGRES_DB=eventol -p 5432:5432 -d postgres | ||
docker run -d -i --name="eventol" --hostname="eventol" -p 8000:8000 --link=eventol-postgres -e PSQL_HOST=eventol-postgres -t eventol:latest | ||
``` | ||
|
||
### Deploy con Docker-Compose | ||
```bash | ||
cd deploy/docker | ||
docker-compose build | ||
docker-compose run -d | ||
``` | ||
|
||
### Deploy en servidor | ||
**TODO** |
Oops, something went wrong.