Docker config to host botsarena on a container

This commit is contained in:
Gnieark 2017-02-01 19:04:40 +01:00
parent 289fc964eb
commit bc52bc889a
9 changed files with 144 additions and 31 deletions

34
Dockerfile Normal file
View File

@ -0,0 +1,34 @@
#Docker image hosting botsarena
FROM tutum/lamp:latest
MAINTAINER Gnieark https://blog-du-grouik.tinad.fr
RUN apt-get update && \
apt-get install -q -y php5-curl
#delete symbolic linc
RUN rm /var/www/html && \
mkdir /var/www/html
#Copy bots arena code
COPY html/ /var/www/html/
COPY src/ /var/www/src/
COPY lang /var/www/lang/
#Some config and mysql scripts
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"]

View File

@ -14,13 +14,15 @@ You are welcome, Make pull requests on branch dev. Im available on twitter [@gni
# install it # install it
I'd better like you to help me to improve [bot's Arena](https://botsarena.tinad.fr/), and you to make your own bots to play challenges. It would be more funny having lot of bots in one arena rather than lot of arenas. I'd better like you to help me to improve [bot's Arena](https://botsarena.tinad.fr/), and you to make your own bots to play challenges. It would be more funny having lot of bots in one arena rather than lot of arenas.
* Mysql structure is in the .sql See dockerFile and associated scripts to understand what is needed.
* Apache/tomcat document root starts at ./html
* copy src/config.php.empty to src/config.php
Apache RewriteRules are given on the file html/.htaccess To test an image of bots arena with docker:
For nginx in server directive: make
docker build .
docker run --name hey -p 127.0.0.1:8080:80 DockerImageId
For nginx Rewrite rules in server directive are:
rewrite '^/([a-zA-Z]{1,})/doc-([a-z]{2})$' /index.php?doc=$1&lang=$2 last; rewrite '^/([a-zA-Z]{1,})/doc-([a-z]{2})$' /index.php?doc=$1&lang=$2 last;
rewrite '^/p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$' /index.php?page=$1&params=$2&lang=$3 last; rewrite '^/p/([a-zA-Z]{1,})/(.*)-([a-z]{2})$' /index.php?page=$1&params=$2&lang=$3 last;

View File

@ -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

14
dockerConfig/run.sh Normal file
View File

@ -0,0 +1,14 @@
#!/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
mysql_install_db > /dev/null 2>&1
/populate_mysql.sh
else
echo "=> Using an existing volume of MySQL"
fi
exec supervisord -n

81
install.sql Executable file → Normal file
View File

@ -1,9 +1,28 @@
-- 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, `game` varchar(8) NOT NULL,
`player1_id` int(11) NOT NULL, `player1_id` int(11) NOT NULL,
`player2_id` int(11) NOT NULL, `player2_id` int(11) NOT NULL,
@ -11,14 +30,17 @@ CREATE TABLE IF NOT EXISTS `arena_history` (
`player2_winsCount` int(11) NOT NULL, `player2_winsCount` int(11) NOT NULL,
`nulCount` 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, `id` int(11) NOT NULL AUTO_INCREMENT,
`name` text NOT NULL, `name` text NOT NULL,
`game` varchar(10) NOT NULL, `game` varchar(10) NOT NULL,
@ -31,25 +53,32 @@ CREATE TABLE IF NOT EXISTS `bots` (
`author_email` text NOT NULL, `author_email` text NOT NULL,
`ELO` int(11) NOT NULL DEFAULT '1500', `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 LOCK TABLES `bots` WRITE;
(2, 'stupidAI', 'tictactoe', 'https://ias.tinad.fr/stupidIATictactoe.php', '', '', 1, '2015-12-03 10:55:34', '', ''), /*!40000 ALTER TABLE `bots` DISABLE KEYS */;
(3, 'stupidAI', 'Battleship', 'https://botsArena.tinad.fr/StupidIABattleship.php', '', '', 1, '2015-12-11 11:16:50', '', ''), INSERT INTO `bots` VALUES
(4, 'stupidAI', 'connectFou', 'https://ias.tinad.fr/StupidIAconnectFour.php', '', '', 1, '2016-05-11 07:47:57', '', ''); (2,'stupidAI','tictactoe','https://ias.tinad.fr/stupidIATictactoe.php','This bot choose the cell to play simply by random.<br />\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, `id` int(11) NOT NULL AUTO_INCREMENT,
`real_id` int(11) NOT NULL, `real_id` int(11) NOT NULL,
`name` text 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, `date_modification` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`validate_secret` varchar(8) NOT NULL, `validate_secret` varchar(8) NOT NULL,
`author_email` text NOT NULL, `author_email` text NOT NULL,
PRIMARY KEY (`id`); PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=latin1; ) 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

@ -1 +0,0 @@
Subproject commit f97b9cd3c2dcf348d110d17613a82614d1163ab5

View File

@ -1 +1,3 @@
<?php <?php
require_once("Alias.php");

View File

@ -10,12 +10,12 @@
# #
# -- END LICENSE BLOCK ----------------------------------------- # -- END LICENSE BLOCK -----------------------------------------
$siteParam=array("BASEURL" => "http://botsarena.tinad.fr/"); $siteParam=array("BASEURL" => "http://localhost/");
$mysqlParams=array( $mysqlParams=array(
'host' => 'localhost', 'host' => 'localhost',
'user' => '', 'user' => 'botsarena',
'pass' => '', 'pass' => 'botsPwd',
'database'=>'' 'database'=>'botsarena'
); );
$smtpParams=array( $smtpParams=array(
//exemple for gmail //exemple for gmail