Skip to content

Instantly share code, notes, and snippets.

@alroniks
Last active July 7, 2023 06:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alroniks/4a09104ef35198171e537e29b94bddb4 to your computer and use it in GitHub Desktop.
Save alroniks/4a09104ef35198171e537e29b94bddb4 to your computer and use it in GitHub Desktop.
TAO Development Docker Environment
MYSQL_PORT=33060
NGINX_PORT=80
PROJECT_NAME=tao

NOTE! This set already out of date. Please, follow this link for find new actual documentation about running TAO in Docker.

This gist with a bunch of files and scripts that will allow using TAO within docker containers.

Below a little instruction how to use it:

  1. At first you need download and install Docker and Docker Compose. (https://www.docker.com/products/overview)
  2. Then you need download ZIP archive from GitHub Gist (https://gist.github.com/Alroniks/4a09104ef35198171e537e29b94bddb4)
  3. After unzipping rename folder as you want. For example: taodoc. This name will be used as project_name.
  4. Init: This step can be skipped, but if you use mac or linux it should work. Run make init in the folder with files. This script will patch project name in config by the name of the current folder.
  5. Run containers: When configs were patched to run our environment make up. Docker will pull images and run containers. By default will be installed latest production release of TAO project. It can take a few minutes while all files from container with tao will be synced with host.
  6. Add domain to /etc/hosts. Domain will be projectname.docker, for example taodoc.docker.

Now you can go to http://taodoc.docker and start install by hands. Or run make install for installation in cli mode.

For go inside container use make shell.

Also available commands: make update for updating project and make down for destroy container. Mysql container use shared data volume so you don’t need to install project after every up. Full list of command in Makefile.

Manual Installation

Here a few screenshots with filled form fields in case when we use taodoc name. If you chose another name, replace taodoc by your name.

Troubleshooting.

  • Such as 80 port can be used only once in the system, init command has option PORT to set different port for instance. Ex: make init PORT=2001, by default 80. For run some projects at the same time I use local nginx with proxied requests to docker instances. Example of config:
upstream mpart {
    server 0.0.0.0:2001;
}

server {
    listen 127.0.0.1:80;
    server_name taodoc.docker;
    root /Users/alroniks/dev/docker/taodoc;
    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://taodoc;
    }
}
  • Not sure that make command will work in Windows but should.
version: '2'
services:
tao:
image: alroniks/tao
restart: always
volumes:
- .:/var/www/html
links:
- dbs
web:
image: nginx
restart: always
ports:
- "${NGINX_PORT}:80"
volumes_from:
- tao
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf
links:
- tao
dbs:
image: mysql
restart: always
ports:
- "${MYSQL_PORT}:3306"
volumes:
- data:/var/lib/mysql:rw
environment:
MYSQL_ROOT_PASSWORD: "${PROJECT_NAME}"
MYSQL_USER: "${PROJECT_NAME}"
MYSQL_PASSWORD: "${PROJECT_NAME}"
MYSQL_DATABASE: "${PROJECT_NAME}"
volumes:
data:
driver: local
#!/bin/sh
NGINX_PORT=80
if [ $1 ]; then
NGINX_PORT=$1
fi
PROJECT_NAME=`basename "$PWD"`
replace "tao.docker" "$PROJECT_NAME.docker" -- nginx.conf
replace "NGINX_PORT=80" "NGINX_PORT=$NGINX_PORT" -- .env
replace "PROJECT_NAME=tao" "PROJECT_NAME=$PROJECT_NAME" -- .env
#!/bin/sh
source .env
PORT=""
if [ $1 != '80' ]; then
PORT=":$1"
fi
dbuser=$PROJECT_NAME
dbpass=$PROJECT_NAME
dbname=$PROJECT_NAME
dbhost="db"
adminuser="admin"
adminpass="QaSx1234!1"
taourl="http://$PROJECT_NAME.docker$PORT"
taons="http://$PROJECT_NAME.docker$PORT/tao.rdf"
taoext="taoCe"
wwwuser="www-data"
mode="debug"
if [ ! -f "tao/manifest.php" ]; then
echo "Please run me in the root of a TAO dist"
exit 1
fi
version=`cat tao/includes/constants.php | grep "'TAO_VERSION'" | sed -r "s/define\('TAO_VERSION',.?'(.*)+'\);/\1/g"`
logfile="config/generis/log.conf.php"
echo ""
echo "Going to install TAO ${version} with extensions $taoext"
echo ""
php tao/scripts/taoInstall.php \
--db_user "${dbuser}" \
--db_pass "${dbpass}" \
--db_host "${dbhost}" \
--db_driver pdo_mysql \
--user_login "${adminuser}" \
--user_pass "${adminpass}" \
--module_url "${taourl}" \
--module_mode "${mode}" \
--db_name "${dbname}" \
--module_namespace "${taons}" \
-e "$taoext"
sleep 1
if [ ! -d "log" ]; then
mkdir ./log
fi
cp ./log.conf.php $logfile
<?php
return [
[
'class' => 'SingleFileAppender',
'threshold' => 1,
'max_file_size' => 1048576,
'rotation-ratio' => .5,
'file' => dirname(__FILE__) . '/../../log/error.txt',
'prefix' => '[dev]'
]
];
.PHONY: init up down shell install
PORT ?= 80
init:
chmod +x init.sh && ./init.sh $(PORT)
up:
docker-compose up -d
down:
docker-compose down
shell:
docker exec -it $(notdir $(CURDIR))_tao_1 bash
install:
docker exec -it $(notdir $(CURDIR))_tao_1 bash install.sh $(PORT)
update:
docker exec -it $(notdir $(CURDIR))_tao_1 php tao/scripts/taoUpdate.php
upstream tao {
server 0.0.0.0:2001;
}
server {
listen 127.0.0.1:80;
server_name tao.docker;
root /Users/alroniks/dev/docker/tao;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://tao;
}
}
server {
index index.php index.html;
server_name tao.docker;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ ^/([^//]*)/(views|locales)/. {}
location /tao/install {}
location /tao/getFile.php {
rewrite ^(.*)$ /tao/getFile.php last;
}
location / {
rewrite ^(.*)$ /index.php;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass tao:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment