From 753d8017a7bc6539cef5a7f0f6e3ee697da7db97 Mon Sep 17 00:00:00 2001 From: Gnieark Date: Wed, 1 Feb 2017 08:17:59 +0100 Subject: [PATCH] dockerFile Work in progress --- Dockerfile | 24 ++++++++++ dockerConfig/populate_mysql.sh | 17 +++++++ dockerConfig/run.sh | 17 +++++++ install.sql | 85 ++++++++++++++++++++++++++-------- src/arenas/tron/functions.php | 2 + src/config.php.empty | 8 ++-- 6 files changed, 129 insertions(+), 24 deletions(-) create mode 100644 Dockerfile create mode 100644 dockerConfig/populate_mysql.sh create mode 100644 dockerConfig/run.sh mode change 100755 => 100644 install.sql diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..6267ba9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,24 @@ +FROM tutum/lamp:latest +#delete symbolic linc +RUN rm /var/www/html && \ + mkdir /var/www/html + +COPY html/ /var/www/html/ +COPY src/ /var/www/src/ +COPY lang /var/www/lang/ + +ADD dockerConfig/populate_mysql.sh /populate_mysql.sh + +RUN cp /var/www/src/config.php.empty /var/www/src/config.php && \ + chmod +x /populate_mysql.sh && \ + chown -R www-data:www-data /var/www + +EXPOSE 80 3306 +ADD install.sql /install.sql +RUN rm /run.sh +ADD dockerConfig/run.sh /run.sh +RUN chmod +x /run.sh + + + +CMD ["/run.sh"] \ No newline at end of file diff --git a/dockerConfig/populate_mysql.sh b/dockerConfig/populate_mysql.sh new file mode 100644 index 0000000..d9b82dc --- /dev/null +++ b/dockerConfig/populate_mysql.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +/usr/bin/mysqld_safe > /dev/null 2>&1 & + +RET=1 +while [[ RET -ne 0 ]]; do + echo "=> Waiting for confirmation of MySQL service startup" + sleep 5 + mysql -uroot -e "status" > /dev/null 2>&1 + RET=$? +done +mysql -u root -e "CREATE database botsarena;" +mysql -u root -e "GRANT ALL on botsarena.* TO 'botsarena'@'localhost' IDENTIFIED BY 'botsPwd';" +mysql -u root botsarena < /install.sql + + +mysqladmin -uroot shutdown diff --git a/dockerConfig/run.sh b/dockerConfig/run.sh new file mode 100644 index 0000000..dcae71f --- /dev/null +++ b/dockerConfig/run.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +VOLUME_HOME="/var/lib/mysql" + +sed -ri -e "s/^upload_max_filesize.*/upload_max_filesize = ${PHP_UPLOAD_MAX_FILESIZE}/" \ + -e "s/^post_max_size.*/post_max_size = ${PHP_POST_MAX_SIZE}/" /etc/php5/apache2/php.ini +if [[ ! -d $VOLUME_HOME/mysql ]]; then + echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME" + echo "=> Installing MySQL ..." + mysql_install_db > /dev/null 2>&1 + echo "=> Done!" + /populate_mysql.sh +else + echo "=> Using an existing volume of MySQL" +fi + +exec supervisord -n diff --git a/install.sql b/install.sql old mode 100755 new mode 100644 index d4ccf65..a3e2e64 --- a/install.sql +++ b/install.sql @@ -1,24 +1,46 @@ +-- MySQL dump 10.13 Distrib 5.5.54, for debian-linux-gnu (x86_64) +-- +-- Host: localhost Database: botsarena +-- ------------------------------------------------------ +-- Server version 5.5.54-0+deb8u1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- --- Structure de la table `arena_history` +-- Table structure for table `arena_history` -- -CREATE TABLE IF NOT EXISTS `arena_history` ( +DROP TABLE IF EXISTS `arena_history`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `arena_history` ( `game` varchar(8) NOT NULL, `player1_id` int(11) NOT NULL, `player2_id` int(11) NOT NULL, `player1_winsCount` int(11) NOT NULL, `player2_winsCount` int(11) NOT NULL, `nulCount` int(11) NOT NULL, - PRIMARY KEY (`game`,`player1_id`,`player2_id`) -); - + PRIMARY KEY (`game`,`player1_id`,`player2_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Structure de la table `bots` +-- Table structure for table `bots` -- -CREATE TABLE IF NOT EXISTS `bots` ( +DROP TABLE IF EXISTS `bots`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bots` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text NOT NULL, `game` varchar(10) NOT NULL, @@ -30,26 +52,33 @@ CREATE TABLE IF NOT EXISTS `bots` ( `validate_secret` varchar(8) NOT NULL, `author_email` text NOT NULL, `ELO` int(11) NOT NULL DEFAULT '1500', - PRIMARY KEY (`id`) -); - + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; -- --- Contenu de la table `bots` only stupid ias +-- Dumping data for table `bots` -- -INSERT INTO `bots` (`id`, `name`, `game`, `url`, `description`, `unclean_description`, `active`, `date_inscription`, `validate_secret`, `author_email`) VALUES -(2, 'stupidAI', 'tictactoe', 'https://ias.tinad.fr/stupidIATictactoe.php', '', '', 1, '2015-12-03 10:55:34', '', ''), -(3, 'stupidAI', 'Battleship', 'https://botsArena.tinad.fr/StupidIABattleship.php', '', '', 1, '2015-12-11 11:16:50', '', ''), -(4, 'stupidAI', 'connectFou', 'https://ias.tinad.fr/StupidIAconnectFour.php', '', '', 1, '2016-05-11 07:47:57', '', ''); +LOCK TABLES `bots` WRITE; +/*!40000 ALTER TABLE `bots` DISABLE KEYS */; +INSERT INTO `bots` VALUES +(2,'stupidAI','tictactoe','https://ias.tinad.fr/stupidIATictactoe.php','This bot choose the cell to play simply by random.
\r\nSon code source: https://github.com/gnieark/IAS/blob/master/stupidIATictactoe.php','This bot choose the cell to play simply by random.\r\nSon code source: https://github.com/gnieark/IAS/blob/master/stupidIATictactoe.php',1,'2015-12-03 10:55:34','','',814), +(3,'stupidIA','Battleship','https://ias.tinad.fr/StupidIABattleship.php','','',1,'2015-12-11 11:16:50','','',1538), +(4,'stupidIA','connectFou','https://ias.tinad.fr/StupidIAconnectFour.php','','',1,'2016-05-11 07:47:57','','',2087), +(5,'stupidIa','tron','http://ias.localhost/stupidIATronBetter.php','','',1,'2016-06-29 07:20:08','','',1677); --- -------------------------------------------------------- +/*!40000 ALTER TABLE `bots` ENABLE KEYS */; +UNLOCK TABLES; -- --- Structure de la table `bots_modifs` +-- Table structure for table `bots_modifs` -- -CREATE TABLE IF NOT EXISTS `bots_modifs` ( +DROP TABLE IF EXISTS `bots_modifs`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `bots_modifs` ( `id` int(11) NOT NULL AUTO_INCREMENT, `real_id` int(11) NOT NULL, `name` text NOT NULL, @@ -60,7 +89,23 @@ CREATE TABLE IF NOT EXISTS `bots_modifs` ( `date_modification` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `validate_secret` varchar(8) NOT NULL, `author_email` text NOT NULL, - PRIMARY KEY (`id`); -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; +/*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Dumping data for table `bots_modifs` +-- +UNLOCK TABLES; +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2017-02-01 8:09:06 diff --git a/src/arenas/tron/functions.php b/src/arenas/tron/functions.php index b3d9bbc..50ae3d9 100755 --- a/src/arenas/tron/functions.php +++ b/src/arenas/tron/functions.php @@ -1 +1,3 @@ "http://botsarena.tinad.fr/"); +$siteParam=array("BASEURL" => "http://localhost/"); $mysqlParams=array( 'host' => 'localhost', - 'user' => '', - 'pass' => '', - 'database'=>'' + 'user' => 'botsarena', + 'pass' => 'botsPwd', + 'database'=>'botsarena' ); $smtpParams=array( //exemple for gmail