Browse Source

Revertendo a alteração do Dockerfile.

pull/1000/head
Edward Ribeiro 8 years ago
parent
commit
3a88bbba8d
  1. 1
      .gitignore
  2. 4
      .travis.yml
  3. 59
      Dockerfile
  4. 10
      busy-wait.sh
  5. 39
      config/nginx/sapl.conf
  6. 19
      docker-compose.yml
  7. 12
      gunicorn_start.sh
  8. 2
      sapl/.env_test
  9. 3
      scripts_docker/shell_sapl.sh

1
.gitignore

@ -93,4 +93,3 @@ bower
bower_components bower_components
media media
whoosh/ whoosh/
postgres-data/

4
.travis.yml

@ -20,7 +20,3 @@ script:
- ./manage.py bower install - ./manage.py bower install
- py.test --create-db - py.test --create-db
# - ./test_and_check_qa.sh # - ./test_and_check_qa.sh
addons:
hosts:
- 127.0.0.1 sapldb

59
Dockerfile

@ -1,26 +1,53 @@
FROM alpine:3.5 FROM ubuntu:15.04
ENV BUILD_PACKAGES postgresql-dev graphviz-dev graphviz build-base git pkgconfig \ RUN locale-gen en_US.UTF-8
python3-dev libxml2-dev jpeg-dev libressl-dev libffi-dev libxslt-dev nodejs py3-lxml \ ENV LANG en_US.UTF-8
py3-magic postgresql-client ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
RUN apk add --no-cache python3 && \ RUN mkdir /sapl
python3 -m ensurepip && \
rm -r /usr/lib/python*/ensurepip && \
pip3 install --upgrade pip setuptools && \
rm -r /root/.cache
RUN mkdir /sapl && apk add --update --no-cache $BUILD_PACKAGES && npm install -g bower RUN echo "deb http://archive.ubuntu.com/ubuntu/ vivid universe" | tee -a "/etc/apt/sources.list"
RUN \
apt-get update && \
apt-get install -y -f \
software-properties-common \
libpq-dev \
graphviz-dev \
graphviz \
build-essential \
git \
pkg-config \
python3-dev \
libxml2-dev \
libjpeg-dev \
libssl-dev \
libffi-dev \
libxslt1-dev \
python3-setuptools \
curl
# use python3 in pip
RUN easy_install3 pip lxml
# install nodejs
RUN DEBIAN_FRONTEND=noninteractive curl -sL https://deb.nodesource.com/setup_5.x | bash -
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y nodejs
# install bower
RUN npm install -g bower
# Bower aceitar root # Bower aceitar root
RUN touch /root/.bowerrc \ RUN touch /root/.bowerrc
&& chmod 751 /root/.bowerrc \ RUN chmod 751 /root/.bowerrc
&& echo "{ \"allow_root\": true }" >> /root/.bowerrc \ RUN echo "{ \"allow_root\": true }" >> /root/.bowerrc
&& npm cache clean
WORKDIR /sapl WORKDIR /sapl
ADD . /sapl ADD . /sapl
RUN pip install -r requirements/dev-requirements.txt --upgrade setuptools --no-cache-dir \ RUN pip install -r requirements/dev-requirements.txt
&& python3 manage.py bower install RUN pip install --upgrade setuptools
# RUN python3 manage.py bower install

10
busy-wait.sh

@ -1,10 +0,0 @@
#!/bin/sh
while true; do
COUNT_PG=`psql --dbname=postgresql://sapl:sapl@sapldb/sapl -c '\l \q' | grep sapl | wc -l`
if ! [ "$COUNT_PG" -eq "0" ]; then
break
fi
echo "Esperando Database Setup"
sleep 10
done

39
config/nginx/sapl.conf

@ -1,39 +0,0 @@
upstream sapl_server {
server unix:/sapl/run/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name sapl.test;
client_max_body_size 4G;
location /static/ {
alias /sapl/collected_static/;
}
location /media/ {
alias /sapl/media/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://sapl_server;
break;
}
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /sapl/sapl/static/;
}
}

19
docker-compose.yml

@ -1,22 +1,9 @@
server: localhost:
image: nginx:latest
ports:
- "80:80"
volumes:
- ./config/nginx:/etc/nginx/conf.d
volumes_from:
- web
links:
- web
sapldb:
image: postgres image: postgres
environment: environment:
POSTGRES_PASSWORD: sapl POSTGRES_PASSWORD: sapl
POSTGRES_USER: sapl POSTGRES_USER: sapl
POSTGRES_DB: sapl POSTGRES_DB: sapl
PGDATA : /var/lib/postgresql/data/
volumes:
- ./postgres-data/data/:/var/lib/postgresql/data/
ports: ports:
- "5532:5432" - "5532:5432"
web: web:
@ -24,5 +11,7 @@ web:
command: /bin/sh -c "/bin/sh busy-wait.sh && python3 manage.py bower install && python3 manage.py migrate && /bin/sh gunicorn_start.sh /sapl" command: /bin/sh -c "/bin/sh busy-wait.sh && python3 manage.py bower install && python3 manage.py migrate && /bin/sh gunicorn_start.sh /sapl"
volumes: volumes:
- .:/sapl - .:/sapl
ports:
- "8000:8000"
links: links:
- sapldb - localhost

12
gunicorn_start.sh

@ -12,17 +12,23 @@ then
fi fi
NAME="SAPL" # Name of the application (*) NAME="SAPL" # Name of the application (*)
DJANGODIR=$SAPL_DIR # Django project directory (*) DJANGODIR=/var/interlegis/sapl # Django project directory (*)
SOCKFILE="$SAPL_DIR/gunicorn.sock" # we will communicate using this unix socket (*) SOCKFILE=/var/interlegis/sapl/run/gunicorn.sock # we will communicate using this unix socket (*)
USER=`whoami` # the user to run as (*) USER=`whoami` # the user to run as (*)
GROUP=`whoami` # the group to run as (*) GROUP=`whoami` # the group to run as (*)
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn (*) NUM_WORKERS=9 # how many worker processes should Gunicorn spawn (*)
# NUM_WORKERS = 2 * CPUS + 1 # NUM_WORKERS = 2 * CPUS + 1
DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*) DJANGO_SETTINGS_MODULE=sapl.settings # which settings file should Django use (*)
DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*) DJANGO_WSGI_MODULE=sapl.wsgi # WSGI module name (*)
echo "Starting $NAME as `whoami` on base dir $SAPL_DIR" echo "Starting $NAME as `whoami` on base dir $SAPL_DIR"
# Activate the virtual environment
cd $DJANGODIR
source /var/interlegis/.virtualenvs/sapl/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist # Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE) RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR test -d $RUNDIR || mkdir -p $RUNDIR

2
sapl/.env_test

@ -1,4 +1,4 @@
DATABASE_URL = postgresql://postgres:@sapldb:/sapl DATABASE_URL = postgresql://postgres:@localhost:/sapl
SECRET_KEY=TravisTest SECRET_KEY=TravisTest
DEBUG=False DEBUG=False
EMAIL_USE_TLS = True EMAIL_USE_TLS = True

3
scripts_docker/shell_sapl.sh

@ -1,3 +1,2 @@
#!/bin/bash #!/bin/bash
docker run -ti sapl_web /bin/bash
docker run --rm -ti sapl_web /bin/sh

Loading…
Cancel
Save