Browse Source

Ajusta diretorio /var/interlegis/sapl e collect_static como volume no nginix

pull/1023/head
Matheus Veleci 9 years ago
parent
commit
7fc6227628
  1. 20
      Dockerfile
  2. 8
      config/nginx/sapl.conf
  3. 10
      docker-compose.yml
  4. 4
      gunicorn_start.sh
  5. 1
      sapl/static/styles/app.css
  6. 1
      sapl/static/styles/compilacao.css
  7. 9
      start.sh

20
Dockerfile

@ -10,7 +10,9 @@ RUN apk add --no-cache python3 && \
pip3 install --upgrade pip setuptools && \
rm -r /root/.cache
RUN mkdir /sapl && apk add --update --no-cache $BUILD_PACKAGES && npm install -g bower
RUN cd /var && mkdir interlegis && cd interlegis && mkdir sapl && cd .. && cd .. &&\
apk add --update --no-cache $BUILD_PACKAGES && \
npm install -g bower
# Bower aceitar root
RUN touch /root/.bowerrc \
@ -18,17 +20,15 @@ RUN touch /root/.bowerrc \
&& echo "{ \"allow_root\": true }" >> /root/.bowerrc \
&& npm cache clean
RUN npm install -g bower
WORKDIR /var/interlegis/sapl/
WORKDIR /sapl
ADD . /var/interlegis/sapl/
ADD . /sapl
COPY start.sh /var/interlegis/sapl/
COPY start.sh /sapl
RUN chmod +x /var/interlegis/sapl/start.sh
RUN chmod +x /sapl/start.sh
RUN pip install -r /var/interlegis/sapl/requirements/requirements.txt --upgrade setuptools
RUN pip install -r requirements/requirements.txt --upgrade setuptools --no-cache-dir
VOLUME ["/sapl/data", "/sapl/media", "/sapl/collected_static"]
ENTRYPOINT ["/sapl/start.sh"]
VOLUME ["/var/interlegis/sapl/data", "/var/interlegis/sapl/media", "/var/interlegis/sapl/collected_static"]
ENTRYPOINT ["/var/interlegis/sapl/start.sh"]

8
config/nginx/sapl.conf

@ -1,6 +1,6 @@
upstream sapl_server {
server unix:/sapl/run/gunicorn.sock fail_timeout=0;
server unix:/var/interlegis/sapl/run/gunicorn.sock fail_timeout=0;
}
@ -12,11 +12,11 @@ server {
client_max_body_size 4G;
location /static/ {
alias /sapl/collected_static/;
alias /var/interlegis/sapl/collected_static/;
}
location /media/ {
alias /sapl/media/;
alias /var/interlegis/sapl/media/;
}
location / {
@ -34,6 +34,6 @@ server {
}
error_page 500 502 503 504 /500.html;
location = /500.html {
root /sapl/sapl/static/;
root /var/interlegis/sapl/sapl/static/;
}
}

10
docker-compose.yml

@ -4,6 +4,8 @@ server:
- "80:80"
volumes:
- ./config/nginx:/etc/nginx/conf.d
- ./collected_static:/var/interlegis/sapl/collected_static
- ./media:/var/interlegis/sapl/media
volumes_from:
- web
sapldb:
@ -14,14 +16,14 @@ sapldb:
POSTGRES_DB: sapl
PGDATA : /var/lib/postgresql/data/
volumes:
- ./postgres-data/data/:/var/lib/postgresql/data/
- ./postgres-data/data/:/var/lib/postgresql/data/
ports:
- "5532:5432"
web:
build: .
volumes:
- .:/sapl
- ./media:/sapl/media
- ./collected_static:/sapl/collected_static
- .:/var/interlegis/sapl/
- ./media:/var/interlegis/sapl/media
- ./collected_static:/var/interlegis/sapl/collected_static
links:
- sapldb

4
gunicorn_start.sh

@ -3,8 +3,8 @@
# As seen in http://tutos.readthedocs.org/en/latest/source/ndg.html
NAME="SAPL" # Name of the application (*)
DJANGODIR=/sapl/ # Django project directory (*)
SOCKFILE=/sapl/run/gunicorn.sock # we will communicate using this unix socket (*)
DJANGODIR=/var/interlegis/sapl/ # Django project directory (*)
SOCKFILE=/var/interlegis/sapl/run/gunicorn.sock # we will communicate using this unix socket (*)
USER=`whoami` # the user to run as (*)
GROUP=`whoami` # the group to run as (*)
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn (*)

1
sapl/static/styles/app.css

File diff suppressed because one or more lines are too long

1
sapl/static/styles/compilacao.css

File diff suppressed because one or more lines are too long

9
start.sh

@ -3,15 +3,15 @@
create_env() {
# check if file exists
if [ ! -f "data/secret.key" ]; then
KEY=`cat data/secret.key`
if [ -f "/var/interlegis/sapl/data/secret.key" ]; then
KEY=`cat /var/interlegis/sapl/data/secret.key`
else
KEY=`python3 genkey.py`
echo $KEY > data/secret.key
fi
# TODO: rename env-test-bash to .env
FILENAME="sapl/.env"
FILENAME="/var/interlegis/sapl/sapl/.env"
if [ -z "${DATABASE_URL:-}" ]; then
DATABASE_URL="postgresql://sapl:sapl@sapldb:5432/sapl"
@ -36,8 +36,7 @@ create_env() {
}
create_env
# python3 gen-env.py
# # python3 gen-env.py
python3 manage.py bower install

Loading…
Cancel
Save