Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
DB_ROOT_PASSWD='secret'
DB_USER='evote'
DB_USER_PASSWD='secret'
DB_NAME='evote'
NGINX_PORT=80
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
RandomLib/vendor
RandomLib/composer.phar
data/slask.php
data/config.php
.DS_Store
.env
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,22 @@ A good strategy of handling the personal codes of a meeting is to create the ele

## Installation guide

### Quickstart for docker
This version of E-vote has been constructed to work with Docker in order for the setup to be quicker than before. Implementationdetails are outlined below.
Rename .env-sample to .env and change the default values. These are used in the setup of the website. Note that `NGINX_PORT` should only be changed if used behind a reverse proxy as the final url must access port 80.

After that run it with
```
docker-compose up
```
This will download the base images (webserver and database), add the files from this project, configure these and then run it. As a final step, open the webbrowser and open `{baseurl}/install/setup.php` and complete the setup there. If developing locally, use `127.0.0.1` since `localhost` does not work. Database `host` will be `mysql`.

#### Docker implementation
Docker-compose creates 3 containers, NGINX which is the webserver, PHP evaluates the PHP sites for NGINX, and mysql which is the database used.

Each of these containers has their own dockerfile for configuring them. NGINX has to include multiple files for configuration, as well as the project files. PHP has to import functionallity to connect to the database, and the database needs a prefilled database.

If the stack is stopped, the data is retained in volumes, and as such if started again will not need new setup.
### Running locally for development/testing

If you are going to develop or test E-vote locally you can use PHP's built-in tools. Simply clone the repo, change directory to the one created by the clone and run
Expand Down
5 changes: 5 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
RandomLib/vendor
RandomLib/composer.phar
data/slask.php
data/config.php
.DS_Store
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
34 changes: 34 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
version: '3'
services:
web:
build:
context: .
dockerfile: dockerfiles/NGINX.dockerfile
ports:
- "${NGINX_PORT}:80"
volumes:
- webfiles:/app
depends_on:
- php
- mysql
php:
build:
context: .
dockerfile: dockerfiles/PHP.dockerfile
volumes:
- webfiles:/app
mysql:
build:
context: .
dockerfile: dockerfiles/MYSQL.dockerfile
environment:
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWD}
MYSQL_USER: ${DB_USER}
MYSQL_PASSWORD: ${DB_USER_PASSWD}
MYSQL_DATABASE: ${DB_NAME}
volumes:
- evote-mysqldata:/var/lib/mysql

volumes:
webfiles:
evote-mysqldata:
3 changes: 3 additions & 0 deletions dockerfiles/MYSQL.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mariadb:latest

ADD app/install/evote.sql /docker-entrypoint-initdb.d/evote.sql
6 changes: 6 additions & 0 deletions dockerfiles/NGINX.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM nginx:latest
COPY nginxconf/nginx.conf /etc/nginx/conf.d/nginx.conf
COPY nginxconf/php.conf /etc/nginx/php.conf
COPY nginxconf/fastcgi_params /etc/nginx/fastcgi_params
COPY ./app/ /app/
RUN chown -R www-data:www-data /app
3 changes: 3 additions & 0 deletions dockerfiles/PHP.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM php:7.4.33-fpm

RUN docker-php-ext-install pdo pdo_mysql mysqli
25 changes: 25 additions & 0 deletions nginxconf/fastcgi_params
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;

fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
23 changes: 23 additions & 0 deletions nginxconf/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
server {
listen 80 default_server;
# server_name evote.<your domain name>;
# access_log /<path to logs>/access.log;
# error_log /<path to logs>/error.log;
root /app;
index index.html index.php;

location ~ \.php$ {
include php.conf;
}


location / {
try_files $uri @evote;
}

# Always rewrite to index.php
location @evote {
rewrite ^(.*)$ /index.php$1 break;
include php.conf;
}
}
4 changes: 4 additions & 0 deletions nginxconf/php.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;