Browse Source

Merge branch 'limesurvey' into 'master'

add limesurvey, fix #74

Closes #74

See merge request oxyta.net/docker-atelier!15
Guilhem Saurel 6 years ago
parent
commit
8da1cd8776

+ 22 - 0
limesurvey/Dockerfile.fpm

@@ -0,0 +1,22 @@
+FROM php:fpm-alpine
+
+RUN apk --no-cache add libpng-dev imap-dev libzip-dev postgresql-dev \
+ && docker-php-ext-install mbstring pdo_pgsql gd imap zip
+
+ENV URL=https://www.limesurvey.org/fr/version-stable?download=2513:limesurvey3155%20181115targz \
+    SHA=ee34369cecd5965b318ed7b2123fa1c66d166a83e89090bd99b7c98758fd22d6 \
+    FILE=limesurvey.tar.gz
+
+RUN wget -q $URL -O $FILE \
+ && echo "$SHA  $FILE" | sha256sum -c \
+ && tar xf $FILE --strip-components=1 \
+ && rm $FILE
+
+RUN chown -R www-data tmp application/config
+ADD config.php application/config/
+
+VOLUME /var/www/html /var/www/html/upload
+
+CMD sed -i "s|POSTGRES_PASSWORD|$POSTGRES_PASSWORD|" application/config/config.php \
+ && chown -R www-data upload \
+ && php-fpm

+ 3 - 0
limesurvey/Dockerfile.nginx

@@ -0,0 +1,3 @@
+FROM nginx:alpine
+
+ADD nginx.conf /etc/nginx/conf.d/default.conf

+ 13 - 0
limesurvey/README.md

@@ -0,0 +1,13 @@
+# Limesurvey
+
+https://www.limesurvey.org/
+
+## Usage
+
+```
+echo POSTGRES_PASSWORD=$(openssl rand -base64 32) >> .env
+docker-compose up -d --build
+docker-compose exec app php application/commands/console.php install "ADMIN_USER" "ADMIN_PASSWORD" "ADMIN_NAME" "ADMIN_EMAIL"
+```
+
+Then you can login on http://limesurvey.${CHATONS_DOMAIN:-localhost}/admin

+ 66 - 0
limesurvey/config.php

@@ -0,0 +1,66 @@
+<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+/*
+| -------------------------------------------------------------------
+| DATABASE CONNECTIVITY SETTINGS
+| -------------------------------------------------------------------
+| This file will contain the settings needed to access your database.
+|
+| For complete instructions please consult the 'Database Connection'
+| page of the User Guide.
+|
+| -------------------------------------------------------------------
+| EXPLANATION OF VARIABLES
+| -------------------------------------------------------------------
+|
+|    'connectionString' Hostname, database, port and database type for
+|     the connection. Driver example: mysql. Currently supported:
+|                 mysql, pgsql, mssql, sqlite, oci
+|    'username' The username used to connect to the database
+|    'password' The password used to connect to the database
+|    'tablePrefix' You can add an optional prefix, which will be added
+|                 to the table name when using the Active Record class
+|
+*/
+return array(
+	'components' => array(
+		'db' => array(
+			'connectionString' => 'pgsql:host=postgres;port=5432;user=postgres;password=POSTGRES_PASSWORD;dbname=postgres;',
+			'emulatePrepare' => true,
+			'username' => 'postgres',
+			'password' => 'POSTGRES_PASSWORD',
+			'charset' => 'utf8',
+			'tablePrefix' => 'lime_',
+		),
+
+		// Uncomment the following lines if you need table-based sessions.
+		// Note: Table-based sessions are currently not supported on MSSQL server.
+		// 'session' => array (
+			// 'class' => 'application.core.web.DbHttpSession',
+			// 'connectionID' => 'db',
+			// 'sessionTableName' => '{{sessions}}',
+		// ),
+
+		'urlManager' => array(
+			'urlFormat' => 'get',
+			'rules' => array(
+				// You can add your own rules here
+			),
+			'showScriptName' => true,
+		),
+
+	),
+	// For security issue : it's better to set runtimePath out of web access
+	// Directory must be readable and writable by the webuser
+	// 'runtimePath'=>'/var/limesurvey/runtime/'
+	// Use the following config variable to set modified optional settings copied from config-defaults.php
+	'config'=>array(
+	// debug: Set this to 1 if you are looking for errors. If you still get no errors after enabling this
+	// then please check your error-logs - either in your hosting provider admin panel or in some /logs directory
+	// on your webspace.
+	// LimeSurvey developers: Set this to 2 to additionally display STRICT PHP error messages and get full access to standard templates
+		'debug'=>0,
+		'debugsql'=>0, // Set this to 1 to enanble sql logging, only active when debug = 2
+		// Update default LimeSurvey config here
+	)
+);
+/* End of file config.php */

+ 44 - 0
limesurvey/docker-compose.yml

@@ -0,0 +1,44 @@
+version: '3'
+
+networks:
+  web:
+    external: true
+
+volumes:
+  data:
+
+services:
+  postgres:
+    image: postgres:11-alpine
+    restart: unless-stopped
+    env_file:
+      - .env
+    volumes:
+      - ${CHATONS_ROOT_DIR:-/srv/chatons}/limesurvey/sql:/var/lib/postgresql/data
+
+  app:
+    build:
+      context: .
+      dockerfile: Dockerfile.fpm
+    restart: unless-stopped
+    env_file:
+      - .env
+    volumes:
+      - data:/var/www/html
+      - ${CHATONS_ROOT_DIR:-/srv/chatons}/limesurvey/upload:/var/www/html/upload
+
+  web:
+    build:
+      context: .
+      dockerfile: Dockerfile.nginx
+    depends_on:
+      - app
+    labels:
+      traefik.enable: "true"
+      traefik.frontend.rule: "Host: limesurvey.${CHATONS_DOMAIN:-localhost}, www.limesurvey.${CHATONS_DOMAIN:-localhost}"
+    networks:
+      - web
+      - default
+    volumes:
+      - data:/var/www/html:ro
+      - ${CHATONS_ROOT_DIR:-/srv/chatons}/limesurvey/upload:/var/www/html/upload:ro

+ 19 - 0
limesurvey/nginx.conf

@@ -0,0 +1,19 @@
+server {
+    listen 80;
+    root /var/www/html;
+    index index.php index.html;
+    location ~ [^/]\.php(/|$) {
+        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
+        if (!-f $document_root$fastcgi_script_name) {
+            return 404;
+        }
+        # Mitigate https://httpoxy.org/ vulnerabilities
+        fastcgi_param HTTP_PROXY "";
+
+        fastcgi_pass app:9000;
+        fastcgi_index index.php;
+
+        include fastcgi_params;
+        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
+    }
+}