Browse Source

Make it work again with readonly mode

Johannes Zellner 9 năm trước cách đây
mục cha
commit
c2a59836f6
7 tập tin đã thay đổi với 148 bổ sung91 xóa
  1. 16 22
      Dockerfile
  2. 1 1
      build.sh
  3. 2 2
      circus.ini
  4. 7 4
      conf.json
  5. 96 0
      nginx.conf
  6. 26 10
      start.sh
  7. 0 52
      taiga.nginx.conf

+ 16 - 22
Dockerfile

@@ -1,39 +1,33 @@
-FROM cloudron/base:0.3.1
-MAINTAINER Taiga Authors <support@cloudron.io>
+FROM cloudron/base:0.8.0
+MAINTAINER Johannes Zellner <support@cloudron.io>
 
 EXPOSE 8000
 
-RUN apt-get update
-RUN apt-get install -y \
-	build-essential binutils-doc autoconf flex bison libjpeg-dev libfreetype6-dev \
-	zlib1g-dev libzmq3-dev libgdbm-dev libncurses5-dev automake libtool libffi-dev curl git tmux \
-	gettext python3 python3-pip python-dev python3-dev virtualenvwrapper libxml2-dev libxslt-dev \
-	postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4 nginx
-
+RUN mkdir -p /app/code
 WORKDIR /app/code
 
+RUN apt-get update && apt-get install -y \
+    build-essential binutils-doc autoconf flex bison libjpeg-dev libfreetype6-dev \
+    zlib1g-dev libzmq3-dev libgdbm-dev libncurses5-dev automake libtool libffi-dev curl git tmux \
+    gettext python3 python3-pip python-dev python3-dev virtualenvwrapper libxml2-dev libxslt-dev \
+    postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4 nginx
+
 ## backend
 RUN git clone https://github.com/taigaio/taiga-back.git taiga-back
-WORKDIR /app/code/taiga-back
-RUN git checkout stable
+RUN cd /app/code/taiga-back && git checkout stable
 
 ## frontend
-WORKDIR /app/code
 RUN git clone https://github.com/taigaio/taiga-front-dist.git taiga-front-dist
-WORKDIR /app/code/taiga-front-dist
-RUN git checkout stable
-
-WORKDIR /app/code
+RUN cd /app/code/taiga-front-dist && git checkout stable
 
+## install all deps in a python virtual env
 ADD build.sh /app/code/build.sh
 RUN /app/code/build.sh
 
-RUN rm /etc/nginx/sites-enabled/default
-ADD taiga.nginx.conf /etc/nginx/sites-enabled/taiga
+RUN rm -rf /var/log/nginx && mkdir /run/nginx && ln -s /run/nginx /var/log/nginx
+RUN rm -f /app/code/taiga-back/settings/local.py && ln -s /run/local.py /app/code/taiga-back/settings/local.py
+RUN rm -f /app/code/taiga-front-dist/dist/conf.json && ln -s /run/conf.json /app/code/taiga-front-dist/dist/conf.json
 
-ADD circus.ini /app/code/circus.ini
-ADD conf.json /app/code/taiga-front-dist/dist/js/conf.json
-ADD local.py /app/code/taiga-back/settings/local.py
-ADD start.sh /app/code/start.sh
+ADD nginx.conf conf.json local.py start.sh /app/code/
 
 CMD [ "/app/code/start.sh" ]

+ 1 - 1
build.sh

@@ -25,4 +25,4 @@ pip install taiga-contrib-ldap-auth
 echo "run migration scripts"
 cd /app/code/taiga-back
 python manage.py collectstatic --noinput
-python manage.py compilemessages
+python manage.py compilemessages

+ 2 - 2
circus.ini

@@ -15,11 +15,11 @@ numprocesses = 1
 autostart = true
 send_hup = true
 stdout_stream.class = FileStream
-stdout_stream.filename = /var/log/gunicorn.stdout.log
+stdout_stream.filename = /run/gunicorn.stdout.log
 stdout_stream.max_bytes = 10485760
 stdout_stream.backup_count = 4
 stderr_stream.class = FileStream
-stderr_stream.filename = /var/log/gunicorn.stderr.log
+stderr_stream.filename = /run/gunicorn.stderr.log
 stderr_stream.max_bytes = 10485760
 stderr_stream.backup_count = 4
 

+ 7 - 4
conf.json

@@ -1,9 +1,13 @@
-
-
 {
     "api": "http://example.com/api/v1/",
     "eventsUrl": "ws://example.com/events",
-    "debug": "true",
+    "eventsMaxMissedHeartbeats": 5,
+    "eventsHeartbeatIntervalTime": 60000,
+    "debug": true,
+    "debugInfo": true,
+    "defaultLanguage": "en",
+    "themes": ["taiga"],
+    "defaultTheme": "taiga",
     "publicRegisterEnabled": false,
     "feedbackEnabled": true,
     "privacyPolicyUrl": null,
@@ -12,4 +16,3 @@
     "loginFormType": "ldap",
     "contribPlugins": []
 }
-

+ 96 - 0
nginx.conf

@@ -0,0 +1,96 @@
+daemon off;
+worker_processes auto;
+pid /run/nginx.pid;
+error_log stderr;
+
+events {
+    worker_connections 768;
+    # multi_accept on;
+}
+
+http {
+
+   ##
+   # Basic Settings
+   ##
+
+   sendfile on;
+   tcp_nopush on;
+   tcp_nodelay on;
+   keepalive_timeout 65;
+   types_hash_max_size 2048;
+
+   include /etc/nginx/mime.types;
+   default_type application/octet-stream;
+
+   client_body_temp_path /run/client_body;
+   proxy_temp_path /run/proxy_temp;
+   fastcgi_temp_path /run/fastcgi_temp;
+   scgi_temp_path /run/scgi_temp;
+   uwsgi_temp_path /run/uwsgi_temp;
+
+   ##
+   # Logging Settings
+   ##
+
+   access_log /dev/stdout;
+
+   ##
+   # Gzip Settings
+   ##
+
+   gzip on;
+   gzip_disable "msie6";
+
+   ##
+   # Virtual Host Configs
+   ##
+
+    server {
+        listen 8000;
+
+        server_name ##HOSTNAME##;
+
+        large_client_header_buffers 4 32k;
+        client_max_body_size 50M;
+        charset utf-8;
+
+        # Frontend
+        location / {
+            root /app/code/taiga-front-dist/dist/;
+            try_files $uri $uri/ /index.html;
+        }
+
+        # Backend
+        location /api {
+            proxy_set_header Host $http_host;
+            proxy_set_header X-Real-IP $remote_addr;
+            proxy_set_header X-Scheme $scheme;
+            proxy_set_header X-Forwarded-Proto $scheme;
+            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+            proxy_pass http://127.0.0.1:8001/api;
+            proxy_redirect off;
+        }
+
+        # Django admin access (/admin/)
+        location /admin {
+            proxy_set_header Host $http_host;
+            proxy_set_header X-Real-IP $remote_addr;
+            proxy_set_header X-Scheme $scheme;
+            proxy_set_header X-Forwarded-Proto $scheme;
+            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+            proxy_pass http://127.0.0.1:8001$request_uri;
+            proxy_redirect off;
+        }
+
+        # Static files
+        location /static {
+            alias /app/code/taiga-back/static;
+        }
+
+        # Media files
+        location /media {
+            alias /app/code/taiga-back/media;
+        }
+    }
+}

+ 26 - 10
start.sh

@@ -17,20 +17,21 @@ sed -e "s/MEDIA_URL = \".*\"/MEDIA_URL = \"https:\/\/${HOSTNAME}\/media\/\"/" \
     -e "s/LDAP_SERVER = \".*\"/LDAP_SERVER = \"ldap:\/\/${LDAP_SERVER}\"/" \
     -e "s/LDAP_PORT = .*/LDAP_PORT = ${LDAP_PORT}/" \
     -e "s/LDAP_SEARCH_BASE = \".*\"/LDAP_SEARCH_BASE = \"${LDAP_USERS_BASE_DN}\"/" \
-    -i /app/code/taiga-back/settings/local.py
-
-# object properties
-sed -e "s/\"NAME\": \".*\",/\"NAME\": \"${POSTGRESQL_DATABASE}\",/" \
+    -e "s/\"NAME\": \".*\",/\"NAME\": \"${POSTGRESQL_DATABASE}\",/" \
     -e "s/\"USER\": \".*\",/\"USER\": \"${POSTGRESQL_USERNAME}\",/" \
     -e "s/\"PASSWORD\": \".*\",/\"PASSWORD\": \"${POSTGRESQL_PASSWORD}\",/" \
     -e "s/\"HOST\": \".*\",/\"HOST\": \"${POSTGRESQL_HOST}\",/" \
     -e "s/\"PORT\": \".*\",/\"PORT\": \"${POSTGRESQL_PORT}\",/" \
-    -i /app/code/taiga-back/settings/local.py
+    /app/code/local.py  > /run/local.py
 
 echo "--> Update conf.json"
-sed -e "s/\"api\": \".*\",/\"api\": \"https:\/\/${HOSTNAME}\/api\/v1\/\",/" \
-    -e "s/\"eventsUrl\": \".*\",/\"eventsUrl\": \"wss:\/\/${HOSTNAME}\/events\",/" \
-    -i /app/code/taiga-front-dist/dist/js/conf.json
+sed -e "s/\"api\": \".*\",/\"api\": \"https:\/\/${APP_DOMAIN}\/api\/v1\/\",/" \
+    -e "s/\"eventsUrl\": \".*\",/\"eventsUrl\": \"wss:\/\/${APP_DOMAIN}\/events\",/" \
+    /app/code/conf.json > /run/conf.json
+
+echo "--> Update nginx.conf"
+sed -e "s,##HOSTNAME##,${APP_DOMAIN}," \
+    /app/code/nginx.conf  > /run/nginx.conf
 
 echo "--> Setup taiga virtual env"
 cd /app/code
@@ -45,8 +46,23 @@ python manage.py loaddata initial_project_templates
 
 cd /app/code
 
+echo "--> Make cloudron own /run"
+chown -R cloudron:cloudron /run
+
 echo "--> Start nginx"
-service nginx restart
+nginx -c /run/nginx.conf &
 
 echo "--> Start taiga-back"
-taiga/bin/circusd /app/code/circus.ini
+PATH=/app/code/taiga/bin:$PATH
+TERM=rxvt-256color
+
+SHELL=/bin/bash
+USER=root
+LANG=en_US.UTF-8
+HOME=/app/code
+PYTHONPATH=/app/code/taiga/lib/python3.4/site-packages
+
+cd /app/code/taiga-back
+
+exec /usr/local/bin/gosu cloudron:cloudron gunicorn -w 1 -t 60 --pythonpath=. -b 127.0.0.1:8001 taiga.wsgi
+# taiga/bin/circusd /app/code/circus.ini

+ 0 - 52
taiga.nginx.conf

@@ -1,52 +0,0 @@
-
-
-server {
-    listen 8000 default_server;
-    server_name _;
-
-    large_client_header_buffers 4 32k;
-    client_max_body_size 50M;
-    charset utf-8;
-
-    access_log /var/log/nginx.access.log;
-    error_log /var/log/nginx.error.log;
-
-    # Frontend
-    location / {
-        root /app/code/taiga-front-dist/dist/;
-        try_files $uri $uri/ /index.html;
-    }
-
-    # Backend
-    location /api {
-        proxy_set_header Host $http_host;
-        proxy_set_header X-Real-IP $remote_addr;
-        proxy_set_header X-Scheme $scheme;
-        proxy_set_header X-Forwarded-Proto $scheme;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_pass http://127.0.0.1:8001/api;
-        proxy_redirect off;
-    }
-
-    # Django admin access (/admin/)
-    location /admin {
-        proxy_set_header Host $http_host;
-        proxy_set_header X-Real-IP $remote_addr;
-        proxy_set_header X-Scheme $scheme;
-        proxy_set_header X-Forwarded-Proto $scheme;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_pass http://127.0.0.1:8001$request_uri;
-        proxy_redirect off;
-    }
-
-    # Static files
-    location /static {
-        alias /app/code/taiga-back/static;
-    }
-
-    # Media files
-    location /media {
-        alias /app/code/taiga-back/media;
-    }
-}
-