From 3ad5c0141bd8f0c93a908442f1d8a40ad076df85 Mon Sep 17 00:00:00 2001 From: Arthur Diniz Date: Sun, 19 May 2019 16:38:50 -0300 Subject: [PATCH] Dockerize boca with php5.6 Signed-off-by: Arthur Diniz --- docker-compose.yml | 40 +++++++++++++++++++++++++++++ docker/Dockerfile | 24 +++++++++++++++++ docker/boca.conf | 18 +++++++++++++ docker/conf.php | 60 +++++++++++++++++++++++++++++++++++++++++++ docker/lsb-release | 1 + docker/production.env | 5 ++++ src/private/conf.php | 21 ++++++++------- 7 files changed, 158 insertions(+), 11 deletions(-) create mode 100644 docker-compose.yml create mode 100644 docker/Dockerfile create mode 100644 docker/boca.conf create mode 100644 docker/conf.php create mode 100644 docker/lsb-release create mode 100644 docker/production.env diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..9c9d250a --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,40 @@ +version: '3.6' +services: + db: + container_name: postgres + image: postgres:9.4 + restart: always + env_file: + - docker/production.env + ports: + - 5432:5432 + networks: + - boca-net + volumes: + - postgres-data:/var/lib/postgresql/data + + boca: + build: + context: . + dockerfile: ./docker/Dockerfile + container_name: boca + restart: always + ports: + - '80:80' + env_file: + - docker/production.env + volumes: + - ./src:/var/www/html + links: + - db + depends_on: + - db + networks: + - boca-net + +volumes: + postgres-data: {} + +networks: + boca-net: + name: boca-net diff --git a/docker/Dockerfile b/docker/Dockerfile new file mode 100644 index 00000000..de07c242 --- /dev/null +++ b/docker/Dockerfile @@ -0,0 +1,24 @@ +FROM php:5.6-apache-stretch + +RUN apt-get update + +# Install Postgre PDO +RUN apt-get install -y libpq-dev \ + && docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql \ + && docker-php-ext-install pdo pdo_pgsql pgsql + +# Install and check lsb-release +RUN apt-get install -y lsb-release quota debootstrap schroot + +COPY docker/boca.conf /etc/apache2/conf-enabled/boca.conf + +ADD docker/lsb-release /etc/lsb-release + +#ADD docker/conf.php /var/www/html/private/conf.php + +#RUN ./icpc/createbocajail.sh + +COPY ./src /var/www/html +WORKDIR /var/www/html + +EXPOSE 80 \ No newline at end of file diff --git a/docker/boca.conf b/docker/boca.conf new file mode 100644 index 00000000..5aa9c8e7 --- /dev/null +++ b/docker/boca.conf @@ -0,0 +1,18 @@ + + AllowOverride Options AuthConfig Limit + Order Allow,Deny + Allow from all + AddDefaultCharset utf-8 + + + AllowOverride None + Deny from all + + + AllowOverride None + Deny from all + + + AllowOverride None + Deny from all + \ No newline at end of file diff --git a/docker/conf.php b/docker/conf.php new file mode 100644 index 00000000..2c7a3d8a --- /dev/null +++ b/docker/conf.php @@ -0,0 +1,60 @@ +. +//////////////////////////////////////////////////////////////////////////////// +// Last modified 05/aug/2012 by cassio@ime.usp.br + +function globalconf() { + $conf["dbencoding"]="UTF8"; + $conf["dbclientenc"]="UTF8"; + $conf['doenc']=false; + + $conf["dblocal"]="false"; // use unix socket to connect? + $conf["dbhost"]="postgres"; + $conf["dbport"]="5432"; + + $conf["dbname"]="bocadb"; // name of the boca database + + $conf["dbuser"]="bocauser"; // unprivileged boca user + $conf["dbpass"]="dAm0HAiC"; + + $conf["dbsuperuser"]="bocauser"; // privileged boca user + $conf["dbsuperpass"]="dAm0HAiC"; + + // note that it is fine to use the same user + + // initial password that is used for the user admin -- set it + // to something hard to guess if the server is available + // online even in the moment you are creating the contest + // In this way, the new accounts for system and admin that are + // eventually created come already with the password set to this + // value. It is your task later to update these passwords to + // some other values within the BOCA web interface. + $conf["basepass"]="boca"; + + // secret key to be used in HTTP headers + // you MUST set it with any random large enough sequence + $conf["key"]="GG56KFJtNDBGjJprR6ex"; + + // the following field is used by the autojudging script + // set it with the ip of the computer running the script + // The real purpose of it is only to differentiate between + // autojudges when multiple computers are used as autojudges + $conf["ip"]='local'; + + return $conf; +} +?> diff --git a/docker/lsb-release b/docker/lsb-release new file mode 100644 index 00000000..1d805b57 --- /dev/null +++ b/docker/lsb-release @@ -0,0 +1 @@ +DISTRIB_CODENAME=stretch \ No newline at end of file diff --git a/docker/production.env b/docker/production.env new file mode 100644 index 00000000..980388f2 --- /dev/null +++ b/docker/production.env @@ -0,0 +1,5 @@ +BOCA_DOMAIN=localhost +POSTGRES_HOST=postgres +POSTGRES_USER=bocauser +POSTGRES_PASSWORD=dAm0HAiC +POSTGRES_DB=bocadb \ No newline at end of file diff --git a/src/private/conf.php b/src/private/conf.php index c35fb6a5..125abc71 100644 --- a/src/private/conf.php +++ b/src/private/conf.php @@ -18,23 +18,23 @@ // Last modified 05/aug/2012 by cassio@ime.usp.br function globalconf() { - $conf["dbencoding"]="UTF8"; - $conf["dbclientenc"]="UTF8"; - $conf['doenc']=false; + $conf["dbencoding"]="UTF8"; + $conf["dbclientenc"]="UTF8"; + $conf['doenc']=false; - $conf["dblocal"]="false"; // use unix socket to connect? -$conf["dbhost"]="localhost"; -$conf["dbport"]="5432"; + $conf["dblocal"]="false"; // use unix socket to connect? + $conf["dbhost"]="localhost"; + $conf["dbport"]="5432"; $conf["dbname"]="bocadb"; // name of the boca database $conf["dbuser"]="bocauser"; // unprivileged boca user -$conf["dbpass"]="dAm0HAiC"; + $conf["dbpass"]="dAm0HAiC"; $conf["dbsuperuser"]="bocauser"; // privileged boca user -$conf["dbsuperpass"]="dAm0HAiC"; + $conf["dbsuperpass"]="dAm0HAiC"; - // note that it is fine to use the same user + // note that it is fine to use the same user // initial password that is used for the user admin -- set it // to something hard to guess if the server is available @@ -47,8 +47,7 @@ function globalconf() { // secret key to be used in HTTP headers // you MUST set it with any random large enough sequence -$conf["key"]="GG56KFJtNDBGjJprR6ex"; - + $conf["key"]="GG56KFJtNDBGjJprR6ex"; // the following field is used by the autojudging script // set it with the ip of the computer running the script