Commit 542a8867 authored by Hermann Mayer's avatar Hermann Mayer

[Config] Added docker configuration.

parent b328d089
FROM php:5.4-apache
MAINTAINER Hermann Mayer <hermann.mayer92@gmail.com>
COPY . /var/www/html/
RUN chmod 755 /var/www/html/var/docker/*
RUN /var/www/html/var/docker/install
EXPOSE 80
ENTRYPOINT ["/var/www/html/var/docker/init"]
CMD ["app:start"]
Requirments
Requirments
---------------------------
You only need a working Doctrine Pear Package to run the schema-tool!
......@@ -39,20 +39,20 @@ doctrine orm:schema-tool:create
<VirtualHost 10.0.0.3:80>
ServerName ebay-tool.hermann-mayer.net
DocumentRoot "/home/htdocs/external/ebay-tool.hermann-mayer.net/public"
ServerName ebay-tool.hermann-mayer.net
DocumentRoot "/home/htdocs/external/ebay-tool.hermann-mayer.net/public"
LogLevel warn
ErrorLog /var/log/httpd/external/ebay-tool.hermann-mayer.net.error.log
CustomLog /var/log/httpd/external/ebay-tool.hermann-mayer.net.access.log combined
LogLevel warn
ErrorLog /var/log/httpd/external/ebay-tool.hermann-mayer.net.error.log
CustomLog /var/log/httpd/external/ebay-tool.hermann-mayer.net.access.log combined
SetEnv APPLICATION_ENV production
SetEnv APPLICATION_ENV production
<Directory "/home/htdocs/external/ebay-tool.hermann-mayer.net/public">
Options -All +ExecCGI +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/home/htdocs/external/ebay-tool.hermann-mayer.net/public">
Options -All +ExecCGI +FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Commands and Paths
SHELL=/bin/bash
CONTAINER_VERSION := 0.3.1
CONTAINER_REGISTRY := e5.lan:5000
CONTAINER_NAME := ebay-tool
CONTAINER_URI := $(CONTAINER_REGISTRY)/$(CONTAINER_NAME):$(CONTAINER_VERSION)
QUICKSTART_CONTAINER := ebay-tool-quickstart
.PHONY: build-image rebuild-image clean-image start-image start-bash-image stop-image image-logs
all: help
help:
##### Docker Image Development #####
# build-image Build the docker container
# rebuild-image Full test cycle, clean, build, start and show logs
# clean-image Remove the builded image
#
##### Docker Image Process control #####
# start-image Start the builded container
# start-bash-image Start a bash shell on the builded container
# stop-image Stop and remove the builded container
# image-logs Show the logs of the container
#####################################
# Docker Image Development
#####################################
build-image:
time docker build -t "$(CONTAINER_URI)" .
start-image: stop-image
docker run --name='$(QUICKSTART_CONTAINER)' -d \
-p 18080:80 \
-e 'DB_USER=root' \
-e 'DB_PASS=' \
-e 'DB_HOST=172.17.42.1' \
-e 'DB_PORT=3306' \
-e 'DB_NAME=ebay_tool' \
-e 'APP_SALT=xxx' \
-e 'APP_RECAPTCHA_PUBKEY=xxx' \
-e 'APP_RECAPTCHA_PRIVKEY=xxx' \
--dns 10.0.0.253 \
"$(CONTAINER_URI)"
@make image-logs
start-bash-image:
docker run -i --name='$(QUICKSTART_CONTAINER)-bash' \
-p 18080:3000 \
"$(CONTAINER_URI)" /bin/bash
stop-image:
docker stop '$(QUICKSTART_CONTAINER)' || exit 0
docker stop '$(QUICKSTART_CONTAINER)-bash' || exit 0
docker rm '$(QUICKSTART_CONTAINER)' || exit 0
docker rm '$(QUICKSTART_CONTAINER)-bash' || exit 0
clean-image: stop-image
docker rmi "$(CONTAINER_URI)" || exit 0
rebuild-image: clean-image build-image start-image image-logs
image-logs:
docker logs -f '$(QUICKSTART_CONTAINER)'
eBay-Tool is a simple product styler for ebay written by Hermann Mayer
# eBay-Tool
eBay-Tool is a simple product styler for product descriptions on ebay.
- [Requirements](#requirements)
- [Production](#production)
- [Development](#development)
- [Getting started](#getting-started)
- [Deployment](#deployment)
- [Quick Start](#quick-start)
- [Available Configuration Parameters](#available-configuration-parameters)
- [Application](#application)
- [Database](#database)
- [E-Mail](#e-mail)
- [Data volumes](#data-volumes)
- [Development](#development-1)
## Requirements
### Production
* A running MySQL server
* A running mail server
### Development
* A running MySQL server, as well
* [apt-cacher-ng](https://www.unix-ag.uni-kl.de/~bloch/acng/)
* Disable with `USE_APT_CACHE=0` on [var/docker/install](var/docker/install)
## Getting started
## Deployment
This application is able to be deployed with the help of docker.
The next sections will help you building a shipable image of the app.
### Quick Start
```bash
# Run the container
$ docker run -d \
-p 10080:80 \
-e 'DB_USER=root' \
-e 'DB_PASS=' \
-e 'DB_HOST=172.17.42.1' \
-e 'DB_PORT=3306' \
-e 'DB_NAME=ebay_tool' \
-e 'APP_SALT=xxx' \
-e 'APP_RECAPTCHA_PUBKEY=xxx' \
-e 'APP_RECAPTCHA_PRIVKEY=xxx' \
"e5.lan:5000/ebay-tool:0.3.1"
```
### Available Configuration Parameters
#### Application
- **APP_SERVERNAME**: Application uri. Defaults to `http://ebay-tool.hermann-mayer.net`.
- **APP_SALT**: Application salt.
- **APP_RECAPTCHA_PUBKEY**: ReCaptcha public key.
- **APP_RECAPTCHA_PRIVKEY**: ReCaptcha private key.
#### Database
- **DB_HOST**: Hostname/IP address of the MySQL server
- **DB_PORT**: Port of the MySQL server. Defaults to `3306`.
- **DB_NAME**: Name of the database. Defaults to `ebay_tool`.
- **DB_USER**: Username for auth. Defaults to `root`.
- **DB_PASS**: Password for auth. Defaults to `~`.
#### E-Mail
- **SMTP_HOST**: SMTP mail server hostname. Defaults to `mail.lan`.
- **SMTP_PORT**: SMTP mail server port. Defaults to `25`.
- **SMTP_SENDER_ADDRESS**: Sender address of any mail. Defaults to `ebay-tool.hermann-mayer.net`.
### Data volumes
Its important to mount a data volume on `/var/www/html/public/extern/images`. This
is the path to all uploaded images. If you don't setup a volume on this path you
will probably loose your uploaded images on a container restart.
Here is simple example:
```bash
# Run the container
$ docker run -d \
-p 10080:80 \
-e 'ALL_YOUR_SETTINGS=xxx' \
-v '/your/host/path:/var/www/html/public/extern/images'
"e5.lan:5000/ebay-tool:0.3.1"
```
### Development
```bash
# Build the container
$ make build-image
# Start the builded container (quickstart)
$ make start-image
# Stop the container
$ make stop-image
# Purge the build - so you could start over with
# another build
$ make clean-image
# See logs for the running container
$ make image-logs
# Start a bash session on the builded container for debugging.
# This command need **clean** or **stop** like the normal **start**.
$ make start-bash-image
```
Feature Request:
------------------------------------
Bugs:
------------------------------------
[development]
app.bootstrap.filepath = APPLICATION_PATH \\"/Module/Bootstrap.php\\"
app.bootstrap.class = Bootstrap
app.version = 2.0.1
app.name = eBay-Tool
app.servername = ${APP_SERVERNAME}
app.default.module = default
app.default.controller = default
app.default.action = index
app.basepath =
app.template.engine = Smarty
app.template.name = simply_elegant
app.template.caching = false
app.uploadpath = APPLICATION_PATH \\"/../public/extern/images/\\"
app.secret.salt = \\"${APP_SALT}\\"
app.recaptcha.pubkey = \\"${APP_RECAPTCHA_PUBKEY}\\"
app.recaptcha.privkey = \\"${APP_RECAPTCHA_PRIVKEY}\\"
app.plugin[] = Plugin_Auth
doctrine.driver = pdo_mysql
doctrine.host = ${DB_HOST}
doctrine.port = ${DB_PORT}
doctrine.user = ${DB_USER}
doctrine.password = ${DB_PASS}
doctrine.dbname = ${DB_NAME}
doctrine.charset = utf8
smarty.tmpl.path = Template
smarty.tmpl.compilepath = cache/template
smarty.cachepath = cache
[production]
app.bootstrap.filepath = APPLICATION_PATH \\"/Module/Bootstrap.php\\"
app.bootstrap.class = Bootstrap
app.version = 2.0.1
app.name = eBay-Tool
app.servername = ${APP_SERVERNAME}
app.default.module = default
app.default.controller = default
app.default.action = index
app.basepath =
app.template.engine = Smarty
app.template.name = simply_elegant
app.template.caching = false
app.uploadpath = APPLICATION_PATH \\"/../public/extern/images/\\"
app.secret.salt = \\"${APP_SALT}\\"
app.recaptcha.pubkey = \\"${APP_RECAPTCHA_PUBKEY}\\"
app.recaptcha.privkey = \\"${APP_RECAPTCHA_PRIVKEY}\\"
app.plugin[] = Plugin_Auth
doctrine.driver = pdo_mysql
doctrine.host = ${DB_HOST}
doctrine.port = ${DB_PORT}
doctrine.user = ${DB_USER}
doctrine.password = ${DB_PASS}
doctrine.dbname = ${DB_NAME}
doctrine.charset = utf8
smarty.tmpl.path = Template
smarty.tmpl.compilepath = cache/template
smarty.cachepath = cache
......@@ -30,7 +30,7 @@ class Bootstrap extends Class_Application_Bootstrap
// Build Connection Array
$dbParams = array(
'driver' => $config['doctrine.driver'],
'unix_socket' => $config['doctrine.unix_socket'],
'port' => $config['doctrine.port'],
'host' => $config['doctrine.host'],
'user' => $config['doctrine.user'],
'password' => $config['doctrine.password'],
......
This diff is collapsed.
<?php echo phpinfo(); ?>
<?php
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail('jack@jity.de', 'subject', 'message', $header);
<VirtualHost *:80>
ServerAdmin root@jity.de
ServerName ebay-tool.hermann-mayer.net
DocumentRoot "/var/www/html/public"
LogLevel warn
ErrorLog /var/log/ebay-tool.de.error.log
CustomLog /var/log/ebay-tool.de.access.log combined
SetEnv APPLICATION_ENV production
<Directory "/var/www/html/public">
AllowOverride All
Order allow,deny
Allow from All
</Directory>
</VirtualHost>
#!/bin/bash
set -e
APP_SERVERNAME=${APP_SERVERNAME:-http://ebay-tool.hermann-mayer.net}
APP_SALT=${APP_SALT:-}
APP_RECAPTCHA_PUBKEY=${APP_RECAPTCHA_PUBKEY:-}
APP_RECAPTCHA_PRIVKEY=${APP_RECAPTCHA_PRIVKEY:-}
DB_HOST=${DB_HOST:-localhost}
DB_PORT=${DB_PORT:-3306}
DB_NAME=${DB_NAME:-ebay_tool}
DB_USER=${DB_USER:-root}
DB_PASS=${DB_PASS}
SMTP_HOST=${SMTP_HOST:-mail.lan}
SMTP_PORT=${SMTP_PORT:-25}
SMTP_SENDER_ADDRESS=${SMTP_SENDER_ADDRESS:-no-reply@ebay-tool.hermann-mayer.net}
APP_INSTALL_DIR="/var/www/html/"
HOSTNAME=`cat /etc/hostname`
# Copy the dist stage config file
(
while IFS= read LINE; do
eval 'printf "%s\\n" "'"$LINE"'"'
done < ${APP_INSTALL_DIR}/application/Config/Application.ini.template
) > ${APP_INSTALL_DIR}/application/Config/Application.ini
# Copy the dist stage php config file
(
while IFS= read LINE; do
eval 'printf "%s\\n" "'"$LINE"'"'
done < /etc/esmtprc.template
) > /etc/esmtprc
# Copy the dist stage esmtp config file
(
while IFS= read LINE; do
eval 'printf "%s\\n" "'"$LINE"'"'
done < /usr/local/etc/php/php.ini.template
) > /usr/local/etc/php/php.ini
appStart () {
export HOME="${APP_INSTALL_DIR}"
echo "Starting apache2 ..."
exec /usr/sbin/apache2 -DFOREGROUND
}
appHelp () {
echo "Available options:"
echo " app:start - Starts all applications (website, docs, blog) (default)"
echo " app:help - Displays the help"
echo " [command] - Execute the specified linux command eg. bash."
}
case "$1" in
app:start)
appStart
;;
app:help)
appHelp
;;
*)
if [ -x $1 ]; then
$1
else
prog=$(which $1)
if [ -n "${prog}" ] ; then
shift 1
$prog $@
else
appHelp
fi
fi
;;
esac
exit 0
#!/bin/bash
set -e
# ------------------------------------------------------
# Config variables
# ------------------------------------------------------
USE_APT_CACHE=1
APP_INSTALL_DIR='/var/www/html'
# ------------------------------------------------------
# Dependencies config (proxy, caching)
# ------------------------------------------------------
echo 'Setup cache proxy sources.list ...'
if [ "$USE_APT_CACHE" = 1 ]; then
cat > /etc/apt/sources.list <<EOF
deb http://storage.lan:3142/http.debian.net/debian jessie main
deb http://storage.lan:3142/http.debian.net/debian jessie-updates main
deb http://storage.lan:3142/security.debian.org jessie/updates main
#deb http://172.17.42.1:3142/http.debian.net/debian jessie main
#deb http://172.17.42.1:3142/http.debian.net/debian jessie-updates main
#deb http://172.17.42.1:3142/security.debian.org jessie/updates main
EOF
else
cat > /etc/apt/sources.list <<EOF
deb http://http.debian.net/debian jessie main
deb http://http.debian.net/debian jessie-updates main
deb http://security.debian.org jessie/updates main
EOF
fi
echo 'Done.'
# ------------------------------------------------------
# Install runtime and build dependencies
# ------------------------------------------------------
# Run the apt-get stuff as a job - for parallel execution
(
# Set some defaults for apt
export DEBIAN_FRONTEND=noninteractive
echo 'Update apt source-lists ...'
apt-get -qq update
echo 'Done.'
echo 'Install build and system dependencies ...'
apt-get --no-install-recommends -qy install \
build-essential python2.7 locales sudo esmtp-run \
libicu-dev icu-devtools vim
echo 'Done.'
echo 'Setup locales ...'
update-locale LANG=C.UTF-8 LC_MESSAGES=POSIX
locale-gen en_US.UTF-8
dpkg-reconfigure locales
echo 'Done.'
) &
jobApt=$!
# ------------------------------------------------------
# Setup configs and runtume environment
# ------------------------------------------------------
# Run this stuff as job - for parallel execution
(
echo 'Enable apache mod_rewrite ...'
a2enmod rewrite
echo 'Done.'
echo 'Install apache vhost config ...'
cp "${APP_INSTALL_DIR}/var/docker/config/ebay-tool-vhost.conf" /etc/apache2/sites-available/000-default.conf
echo 'IncludeOptional sites-enabled/*.conf' >> /etc/apache2/apache2.conf
echo 'Done.'
echo 'Write a esmtprc ...'
cat > /etc/esmtprc.template <<EOF
hostname=\${SMTP_HOST}:\${SMTP_PORT}
force reverse_path=\${SMTP_SENDER_ADDRESS}
EOF
echo 'Done.'
echo 'Setup permission on project source ...'
chown www-data:www-data -R "${APP_INSTALL_DIR}"
echo 'Done.'
) &
jobRuntimeConf=$!
# ------------------------------------------------------
# Build and install php extensions
# ------------------------------------------------------
# Wait for the runtime jobs
wait "$jobApt" "$jobRuntimeConf"
# Run the builds as jobs - for parallel execution
(
echo 'Build and install apc php extension ...'
yes '' | pecl install -f apc
cat > /usr/local/etc/php/conf.d/apc.ini <<EOF
extension = apc.so
apc.enabled = 1
apc.gc_ttl = 7200
apc.ttl = 7200
apc.shm_size = 256M
apc.mmap_file_mask = /apc.shm.XXXXXX
apc.file_md5 = 1
apc.canonicalize = 1
EOF
echo 'Done.'
) &
jobBuildAPC=$!
(
echo 'Build and install common php extensions via docker php image script ...'
/usr/local/bin/docker-php-ext-install \
intl pdo_mysql mbstring
echo 'Done.'
) &
jobBuildCommon=$!
# ------------------------------------------------------
# Configure php
# ------------------------------------------------------
# Wait for build jobs
wait "$jobBuildAPC" "$jobBuildCommon"
(
echo 'Write a php.ini ...'
cat > /usr/local/etc/php/php.ini.template <<EOF
[PHP]
short_open_tag = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
memory_limit = 128M
display_errors = On
display_startup_errors = On
error_log = /tmp/php.err.log
log_errors = On
[Date]
date.timezone = "Europe/Berlin"
date.default_latitude = 52.5194
date.default_longitude = 13.4067
[mail function]
SMTP = \${SMTP_HOST}
smtp_port = \${SMTP_PORT}
mail.add_x_header = On
sendmail_path=/usr/sbin/sendmail -t -i
EOF
echo 'Done.'
) &
jobConfigPHP=$!
# ------------------------------------------------------
# Cleanup the image
# ------------------------------------------------------
# Wait for config jobs
wait "$jobConfigPHP"
# # Run the apt-get stuff as a job - for parallel execution
# (
# # Clean up the container
# echo 'Remove build-only dependencies ...'
# apt-get -qy --purge autoremove \
# build-essential python2.7
# echo 'Done.'
#
# echo 'Clear the package download cache ...'
# apt-get -qy clean
# echo 'Done.'
#
# echo 'Clear the apt lists cache ...'
# rm -rf /var/lib/apt/lists/*
# echo 'Done.'
#
# echo 'Clear system cache /tmp ...'
# rm -rf /tmp/*
# echo 'Done.'
# ) &
# jobAptClear=$!
#
# # ------------------------------------------------------
# # Finish
# # ------------------------------------------------------
#
# # Wait for the clear jobs - if they are done we finished the install
# wait "$jobAptClear"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment