diff --git a/.gitignore b/.gitignore index bda9574..20a0027 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ composer.lock vendor/ bower_components/ examples/magento-lb-master-slave/htdocs/ +examples/ruby-on-rails-mod-passenger/ror/ diff --git a/container/container.go b/container/container.go index 31a9271..0556fa1 100644 --- a/container/container.go +++ b/container/container.go @@ -221,6 +221,12 @@ func (c *Container) GetCustomValue(params ...string) interface{} { return nil } +func (c *Container) SetCustomValue(name, value string) string { + c.Custom[name] = value + + return "" +} + func (c *Container) GetCustomValueAsString(params ...string) string { if value, ok := c.Custom[params[0]]; ok { return value.(string) @@ -261,6 +267,15 @@ func (c *Container) FirstLinked() *Container { return nil } + +func (c *Container) GetFirstMountedDir() string { + for _, volume := range c.Volumes { + return volume + } + + return "" +} + func (c *Container) DependsOf(otherComponentType string) bool { for _, dep := range c.Dependencies { if dep.Type == otherComponentType { diff --git a/examples/ruby-on-rails-mod-passenger/.gaudi.yml b/examples/ruby-on-rails-mod-passenger/.gaudi.yml new file mode 100644 index 0000000..5b3c339 --- /dev/null +++ b/examples/ruby-on-rails-mod-passenger/.gaudi.yml @@ -0,0 +1,20 @@ +applications: + app: + type: ror + volumes: + .: /app + ports: + 8080: 8080 + links: [db] + custom: + project_name: ror + documentRoot: /app/ror/public + serverType: apache + + db: + type: mysql + ports: + 3306: 3306 + after_script: mysql -e "CREATE DATABASE IF NOT EXISTS ror_development CHARACTER SET utf8 COLLATE utf8_general_ci;" -uroot + volumes: + .gaudi/mysql: /var/lib/mysql diff --git a/examples/ruby/.gaudi.yml b/examples/ruby/.gaudi.yml new file mode 100644 index 0000000..3b9fdbe --- /dev/null +++ b/examples/ruby/.gaudi.yml @@ -0,0 +1,11 @@ +applications: + app: + type: ruby + volumes: + .: /app + after_script: ruby /app/hello.rb + #custom: + # version: 2.1.2 + +# sudo gaudi +# sudo docker logs app diff --git a/examples/ruby/hello.rb b/examples/ruby/hello.rb new file mode 100644 index 0000000..44379a6 --- /dev/null +++ b/examples/ruby/hello.rb @@ -0,0 +1 @@ +puts "Hello from ruby\n" diff --git a/templates/_includes/beforeAfterScripts.txt b/templates/_includes/beforeAfterScripts.txt index 4959e7d..087745f 100644 --- a/templates/_includes/beforeAfterScripts.txt +++ b/templates/_includes/beforeAfterScripts.txt @@ -1,19 +1,19 @@ [[ if (.Container.HasBeforeScript) ]] - [[ if (.Container.HasBeforeScriptFile) ]] - ADD [[.Container.BeforeScript]] /root/before-setup.sh - [[ else ]] - RUN echo '[[.Container.BeforeScript]]' > /root/before-setup.sh - [[ end ]] + [[ if (.Container.HasBeforeScriptFile) ]] + ADD [[.Container.BeforeScript]] /root/before-setup.sh + [[ else ]] + RUN echo '[[.Container.BeforeScript]]' > /root/before-setup.sh + [[ end ]] - RUN chmod +x /root/before-setup.sh + RUN chmod +x /root/before-setup.sh [[ end ]] [[ if (.Container.HasAfterScript) ]] - [[ if (.Container.HasAfterScriptFile) ]] - ADD [[.Container.AfterScript]] /root/after-setup.sh - [[ else ]] - RUN echo '[[.Container.AfterScript]]' > /root/after-setup.sh - [[ end ]] + [[ if (.Container.HasAfterScriptFile) ]] + ADD [[.Container.AfterScript]] /root/after-setup.sh + [[ else ]] + RUN echo '[[.Container.AfterScript]]' > /root/after-setup.sh + [[ end ]] - RUN chmod +x /root/after-setup.sh + RUN chmod +x /root/after-setup.sh [[ end ]] diff --git a/templates/_includes/installNodeJS.txt b/templates/_includes/installNodeJS.txt new file mode 100644 index 0000000..ff4e872 --- /dev/null +++ b/templates/_includes/installNodeJS.txt @@ -0,0 +1,6 @@ +# Install nodejs with nvm +[[ $nodeVersion := .Container.GetCustomValue "nodeVersion" (.Container.GetCustomValue "version" "0.10.20")]] + +RUN git clone https://github.com/creationix/nvm.git /.nvm +#RUN echo "/.nvm/nvm.sh" >> /etc/bash.bashrc +RUN /bin/bash -c '. /.nvm/nvm.sh && nvm install v[[ $nodeVersion ]] && nvm use v[[ $nodeVersion ]] && nvm alias default v[[ $nodeVersion ]] && ln -s /.nvm/v[[ $nodeVersion ]]/bin/node /usr/bin/node && ln -s /.nvm/v[[ $nodeVersion ]]/bin/npm /usr/bin/npm' diff --git a/templates/_includes/installRvm.txt b/templates/_includes/installRvm.txt new file mode 100644 index 0000000..1879dcb --- /dev/null +++ b/templates/_includes/installRvm.txt @@ -0,0 +1,14 @@ +# Install ruby via RVM +[[ $version := (.Container.GetCustomValue "version" "2.1.2") ]] + +RUN apt-get install -y --reinstall procps +RUN curl -L https://get.rvm.io | bash -s stable + +ENV PATH /usr/local/rvm/bin/:$PATH +ENV PATH /usr/local/rvm/rubies/ruby-[[ $version ]]/bin/:$PATH +ENV PATH /usr/local/rvm/gems/ruby-[[ $version ]]/bin/:$PATH + +RUN rvm install [[ $version ]] +RUN rvm use [[ $version ]] --default + + diff --git a/templates/ambassador/Dockerfile b/templates/ambassador/Dockerfile index 55555f8..fb55573 100644 --- a/templates/ambassador/Dockerfile +++ b/templates/ambassador/Dockerfile @@ -5,5 +5,5 @@ FROM stackbrew/debian:wheezy RUN apt-get install -y -f socat -CMD env | grep _TCP= | sed 's/.*_PORT_\([0-9]*\)_TCP=tcp:\/\/\(.*\):\(.*\)/socat TCP4-LISTEN:\1,fork,reuseaddr TCP4:\2:\3 \&/' | sh \ - && /bin/bash +CMD env | grep _TCP= | sed 's/.*_PORT_\([0-9]*\)_TCP=tcp:\/\/\(.*\):\(.*\)/socat TCP4-LISTEN:\1,fork,reuseaddr TCP4:\2:\3 \&/' | sh \ + && /bin/bash diff --git a/templates/apache/000-default b/templates/apache/000-default index d4e4c13..c846660 100644 --- a/templates/apache/000-default +++ b/templates/apache/000-default @@ -1,57 +1,59 @@ - ServerAdmin webmaster@localhost - - [[ $documentRoot := (.Container.GetCustomValue "documentRoot") ]] - [[ if $documentRoot ]] - DocumentRoot [[ $documentRoot ]] - [[ else ]] - DocumentRoot /var/www - [[ end ]] - - Options FollowSymLinks - AllowOverride None - - - [[ if $documentRoot ]] + ServerAdmin webmaster@localhost + + [[ $documentRoot := (.Container.GetCustomValue "documentRoot") ]] + [[ if $documentRoot ]] + DocumentRoot [[ $documentRoot ]] + [[ else ]] + DocumentRoot /var/www + [[ end ]] + + Options FollowSymLinks + AllowOverride None + + + [[ if $documentRoot ]] [[ else ]] [[ end ]] - Options Indexes FollowSymLinks MultiViews - AllowOverride All - Order allow,deny - allow from all - + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + - [[ if(.Container.DependsOf "django" )]] - [[ $django := (.Collection.GetType "django") ]] - WSGIScriptAlias / /app/[[ (.Collection.GetType "django").GetCustomValue "project_name" "project" ]]/wsgi.py + [[ if(.Container.DependsOf "django" )]] + [[ $django := (.Collection.GetType "django") ]] + WSGIScriptAlias / /app/[[ $django.GetCustomValue "project_name" "project" ]]/wsgi.py Alias /static/admin /usr/local/lib/python2.7/dist-packages/django/contrib/admin/static/admin Alias /static/ /app/[[ $django.GetCustomValue "project_name" "project" ]]/[[ $django.GetCustomValue "app_name" "myapp" ]]/static/ Alias /uploads/ /app/uploads/ - [[ end ]] + [[ end ]] + + + AllowOverride None + Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch + Order allow,deny + Allow from all + - - AllowOverride None - Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch - Order allow,deny - Allow from all - + ErrorLog ${APACHE_LOG_DIR}/error.log - ErrorLog ${APACHE_LOG_DIR}/error.log + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn - # Possible values include: debug, info, notice, warn, error, crit, - # alert, emerg. - LogLevel warn + CustomLog ${APACHE_LOG_DIR}/access.log combined - CustomLog ${APACHE_LOG_DIR}/access.log combined + [[ $fastCgi := .Collection.Get (.Container.GetCustomValueAsString "fastCgi") (.Collection.GetType "php-fpm") ]] + [[ if $fastCgi ]] + [[ $fastCgiIdleTimeout := .Container.GetCustomValue "fastCgiIdleTimeout" "30" ]] + [[ $fastCgiPath := "/var/www/cgi-bin/php5.external" ]] - [[ $fastCgi := .Collection.Get (.Container.GetCustomValueAsString "fastCgi") (.Collection.GetType "php-fpm") ]] - [[ $fastCgiIdleTimeout := .Container.GetCustomValue "fastCgiIdleTimeout" "30" ]] - [[ if $fastCgi ]] - FastCgiExternalServer /var/www/cgi-bin/php5.external -host ${[[ $fastCgi.Name | ToUpper ]]_PORT_[[ $fastCgi.GetFirstLocalPort ]]_TCP_ADDR}:${[[ $fastCgi.Name | ToUpper ]]_PORT_[[ $fastCgi.GetFirstLocalPort]]_TCP_PORT} -idle-timeout [[ $fastCgiIdleTimeout ]] - Alias /cgi-bin/ /var/www/cgi-bin/ - [[end]] + FastCgiExternalServer [[ $fastCgiPath ]] -host ${[[ $fastCgi.Name | ToUpper ]]_PORT_[[ $fastCgi.GetFirstLocalPort ]]_TCP_ADDR}:${[[ $fastCgi.Name | ToUpper ]]_PORT_[[ $fastCgi.GetFirstLocalPort]]_TCP_PORT} -idle-timeout [[ $fastCgiIdleTimeout ]] + Alias /cgi-bin/ /var/www/cgi-bin/ + [[end]] diff --git a/templates/apache/Dockerfile b/templates/apache/Dockerfile index afee499..b1ac472 100644 --- a/templates/apache/Dockerfile +++ b/templates/apache/Dockerfile @@ -6,24 +6,23 @@ RUN echo "deb-src http://ftp.fr.debian.org/debian/ wheezy non-free" >> /etc/apt/ [[ updateApt ]] [[ addUserFiles ]] -RUN apt-get install -y -f apache2-mpm-worker libapache2-mod-fastcgi php5-fpm -RUN sed -i 's/;pm.start_servers/pm.start_servers/g' /etc/php5/fpm/pool.d/www.conf +RUN apt-get install -y -f apache2-mpm-worker libapache2-mod-fastcgi RUN a2enmod actions fastcgi alias [[range (.Container.GetCustomValue "modules")]] - RUN a2enmod [[.]] + RUN a2enmod [[.]] [[end]] RUN service apache2 reload [[ if(.Container.DependsOf "django" )]] - RUN apt-get install -y -f python2.7 python-dev python-setuptools libmysqlclient-dev - RUN easy_install pip - RUN pip install django==1.6 - RUN pip install mysql-python + RUN apt-get install -y -f python2.7 python-dev python-setuptools libmysqlclient-dev + RUN easy_install pip + RUN pip install django==1.6 + RUN pip install mysql-python - RUN apt-get install -y -f libapache2-mod-wsgi + RUN apt-get install -y -f libapache2-mod-wsgi - RUN echo "WSGIPythonPath /app/[[ (.Collection.GetType "django").GetCustomValue "project_name" "project" ]]:/usr/local/lib/python2.7/site-packages" >> /etc/apache2/httpd.conf + RUN echo "WSGIPythonPath /app/[[ (.Collection.GetType "django").GetCustomValue "project_name" "project" ]]:/usr/local/lib/python2.7/site-packages" >> /etc/apache2/httpd.conf [[ end ]] # Add setup script @@ -35,16 +34,18 @@ ADD 000-default /etc/apache2/sites-enabled/000-default ADD ports.conf /etc/apache2/ports.conf [[ $fastCgi := .Collection.Get (.Container.GetCustomValueAsString "fastCgi") (.Collection.GetType "php-fpm") ]] -[[ if $fastCgi ]] - [[ $memoryLimit := $fastCgi.GetCustomValue "memoryLimit" "128M" ]] +[[ if and $fastCgi (or (eq $fastCgi.Type "php-fpm") (eq $fastCgi.Type "hhvm"))]] + [[ $memoryLimit := $fastCgi.GetCustomValue "memoryLimit" "128M" ]] [[ $maxExecutionTime := $fastCgi.GetCustomValue "maxExecutionTime" "30" ]] [[ $maxInputTime := $fastCgi.GetCustomValue "maxInputTime" "60" ]] [[ $locale := $fastCgi.GetCustomValue "locale" "Europe/Paris" ]] - RUN sed -i 's|;date.timezone =|date.timezone = "[[ $locale ]]"|g' /etc/php5/fpm/php.ini + RUN apt-get install -y -f php5-fpm + RUN sed -i 's|;date.timezone =|date.timezone = "[[ $locale ]]"|g' /etc/php5/fpm/php.ini RUN sed -i 's|memory_limit = 128M|memory_limit = [[ $memoryLimit ]]|g' /etc/php5/fpm/php.ini RUN sed -i 's|max_execution_time = 30|max_execution_time = [[ $maxExecutionTime ]]|g' /etc/php5/fpm/php.ini RUN sed -i 's|max_input_time = 60|max_input_time = [[ $maxInputTime ]]|g' /etc/php5/fpm/php.ini + RUN sed -i 's|;pm.start_servers|pm.start_servers|g' /etc/php5/fpm/pool.d/www.conf [[ end ]] # Add custom setup script [[ beforeAfterScripts ]] @@ -53,7 +54,7 @@ ADD ports.conf /etc/apache2/ports.conf CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ - && /etc/init.d/apache2 start \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - && /bin/bash + && /etc/init.d/apache2 start \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /bin/bash [[ end ]] diff --git a/templates/apache/fastcgi.conf b/templates/apache/fastcgi.conf index 9a4fee9..2849d41 100644 --- a/templates/apache/fastcgi.conf +++ b/templates/apache/fastcgi.conf @@ -1,10 +1,10 @@ - AddHandler php5-fcgi .php - Action php5-fcgi /cgi-bin/php5.external + AddHandler php5-fcgi .php + Action php5-fcgi /cgi-bin/php5.external - - Order Deny,Allow - Deny from All - Allow from env=REDIRECT_STATUS - + + Order Deny,Allow + Deny from All + Allow from env=REDIRECT_STATUS + diff --git a/templates/bower/Dockerfile b/templates/bower/Dockerfile index d154698..2986407 100644 --- a/templates/bower/Dockerfile +++ b/templates/bower/Dockerfile @@ -3,12 +3,7 @@ FROM stackbrew/debian:wheezy [[ updateApt ]] [[ addUserFiles ]] -[[ $version := .Container.GetCustomValue "fastCgi" "0.10.20"]] - -# Install nodejs with nvm -RUN git clone https://github.com/creationix/nvm.git /.nvm -RUN echo "/.nvm/nvm.sh" >> /etc/bash.bashrc -RUN /bin/bash -c '. /.nvm/nvm.sh && nvm install v[[ $version ]] && nvm use v[[ $version ]] && nvm alias default v[[ $version ]] && ln -s /.nvm/v[[ $version ]]/bin/node /usr/bin/node && ln -s /.nvm/v[[ $version ]]/bin/npm /usr/bin/npm' +[[ installNodeJS ]] # Install NPM RUN curl https://www.npmjs.org/install.sh | clean=no sh diff --git a/templates/cassandra/Dockerfile b/templates/cassandra/Dockerfile index eb821ca..7695a3e 100644 --- a/templates/cassandra/Dockerfile +++ b/templates/cassandra/Dockerfile @@ -15,7 +15,7 @@ RUN sed -i -e "s/rpc_address:\slocalhost/rpc_address: 0.0.0.0/" /etc/cassandra/c RUN sed -i -e "s/#MAX_HEAP_SIZE=\"4G\"/MAX_HEAP_SIZE=\"[[ (.Container.GetCustomValue "maxHeapSize" "512M") ]]\"/" /etc/cassandra/cassandra-env.sh RUN sed -i -e "s/#HEAP_NEWSIZE=\"800M\"/HEAP_NEWSIZE=\"[[ (.Container.GetCustomValue "heapNewSize" "128M") ]]\"/" /etc/cassandra/cassandra-env.sh -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD /etc/init.d/cassandra start && /bin/bash diff --git a/templates/django/Dockerfile b/templates/django/Dockerfile index f4d2b34..5960f14 100644 --- a/templates/django/Dockerfile +++ b/templates/django/Dockerfile @@ -6,7 +6,7 @@ RUN echo "deb-src http://ftp.fr.debian.org/debian/ wheezy non-free" >> /etc/apt/ [[ updateApt ]] [[ addUserFiles ]] -WORKDIR /app +WORKDIR [[ .Container.GetFirstMountedDir ]] RUN apt-get install -y -f python2.7 python-dev python-setuptools libmysqlclient-dev RUN easy_install pip @@ -15,7 +15,7 @@ RUN pip install mysql-python RUN pip install south [[range (.Container.GetCustomValue "pip_modules")]] - RUN pip install [[.]] + RUN pip install [[.]] [[end]] # Add setup script @@ -25,13 +25,13 @@ RUN chmod +x /root/setup.sh # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - [[ if eq (.Collection.IsComponentDependingOf .Container "apache") false ]] - && python manage.py runserver 0.0.0.0:[[ .Container.GetFirstLocalPort "8000" ]] \ - [[end]] - && /bin/bash + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + [[ if eq (.Collection.IsComponentDependingOf .Container "apache") false ]] + && python manage.py runserver 0.0.0.0:[[ .Container.GetFirstLocalPort "8000" ]] \ + [[end]] + && /bin/bash [[ end ]] diff --git a/templates/django/setup.sh b/templates/django/setup.sh index 78a4534..54063d0 100644 --- a/templates/django/setup.sh +++ b/templates/django/setup.sh @@ -1,23 +1,25 @@ -if [ ! -d "/app/[[ .Container.GetCustomValue "project_name" "project" ]]/[[ .Container.GetCustomValue "app_name" "myapp" ]]" ]; then - [[ $projectName := .Container.GetCustomValue "project_name" "project" ]] - [[ $appName := .Container.GetCustomValue "app_name" "myapp" ]] +[[ $dir := .Container.GetFirstMountedDir ]] +[[ $projectName := .Container.GetCustomValue "project_name" "project" ]] +[[ $appName := .Container.GetCustomValue "app_name" "myapp" ]] - # Install django & configure it - cd /app - django-admin.py startproject [[ $projectName ]] . +if [ ! -d "[[$dir]]/[[ $projectName ]]/[[ $appName ]]" ]; then - mkdir ./[[ $projectName ]]/[[ $appName]] - python ./manage.py startapp [[ $appName ]] ./[[ $projectName ]]/[[ $appName ]] + # Install django & configure it + cd [[$dir]] + django-admin.py startproject [[ $projectName ]] . - [[ $firstLinked := .Container.FirstLinked]] + mkdir ./[[ $projectName ]]/[[ $appName]] + python ./manage.py startapp [[ $appName ]] ./[[ $projectName ]]/[[ $appName ]] - cd /app/[[ $projectName ]] - sed -i -e "s/'django.db.backends.sqlite3'/'django.db.backends.mysql'/" ./settings.py - sed -i -e "s/'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),/'NAME': 'django',\n\t\t'USER': 'root',\n\t\t'PASSWORD': '',\n\t\t'HOST': os.environ['[[ $firstLinked.Name | ToUpper ]]_PORT_[[ $firstLinked.GetFirstLocalPort]]_TCP_ADDR']/" ./settings.py + [[ $firstLinked := .Container.FirstLinked]] - sed -i -e "s/# from django.contrib import admin/from django.contrib import admin/" ./urls.py - sed -i -e "s/# admin.autodiscover()/admin.autodiscover()/" ./urls.py - sed -i -e "s/# url(r'^admin\/', include(admin.site.urls))/url(r'^admin\/', include(admin.site.urls))/" ./urls.py + cd [[$dir]]/[[ $projectName ]] + sed -i -e "s/'django.db.backends.sqlite3'/'django.db.backends.mysql'/" ./settings.py + sed -i -e "s/'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),/'NAME': 'django',\n\t\t'USER': 'root',\n\t\t'PASSWORD': '',\n\t\t'HOST': os.environ['[[ $firstLinked.Name | ToUpper ]]_PORT_[[ $firstLinked.GetFirstLocalPort]]_TCP_ADDR']/" ./settings.py - echo -e "import os, sys\nbase = os.path.dirname(os.path.dirname(__file__))\nbase_parent = os.path.dirname(base)\nsys.path.append(base)\nsys.path.append(base_parent)\n\n$(cat /app/[[ $projectName ]]/wsgi.py)" > /app/[[ $projectName ]]/wsgi.py + sed -i -e "s/# from django.contrib import admin/from django.contrib import admin/" ./urls.py + sed -i -e "s/# admin.autodiscover()/admin.autodiscover()/" ./urls.py + sed -i -e "s/# url(r'^admin\/', include(admin.site.urls))/url(r'^admin\/', include(admin.site.urls))/" ./urls.py + + echo -e "import os, sys\nbase = os.path.dirname(os.path.dirname(__file__))\nbase_parent = os.path.dirname(base)\nsys.path.append(base)\nsys.path.append(base_parent)\n\n$(cat [[$dir]]/[[ $projectName ]]/wsgi.py)" > [[$dir]]/[[ $projectName ]]/wsgi.py fi diff --git a/templates/golang/Dockerfile b/templates/golang/Dockerfile index 4b94fc4..82a9bde 100644 --- a/templates/golang/Dockerfile +++ b/templates/golang/Dockerfile @@ -17,15 +17,15 @@ ENV PATH $PATH:/usr/local/go/bin:$GOPATH/bin # Install deps [[range (.Container.GetCustomValue "modules")]] - RUN go get [[.]] + RUN go get [[.]] [[end]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] - [[ if (.Container.HasAfterScript) ]] - CMD [[.Container.AfterScript]] && /bin/bash - [[ else ]] - CMD ["go version"] && /bin/bash - [[ end]] + [[ if (.Container.HasAfterScript) ]] + CMD [[.Container.AfterScript]] && /bin/bash + [[ else ]] + CMD ["go version"] && /bin/bash + [[ end]] [[ end ]] diff --git a/templates/hhvm/Dockerfile b/templates/hhvm/Dockerfile index 0c893a8..be42d70 100644 --- a/templates/hhvm/Dockerfile +++ b/templates/hhvm/Dockerfile @@ -14,7 +14,7 @@ RUN apt-get install -y --force-yes -f hhvm php5-cli curl [[ $maxExecutionTime := .Container.GetCustomValue "maxExecutionTime" "30" ]] RUN sed -i -e 's|; php options|; php options\nmemory_limit = [[ $memoryLimit ]]\nmax_execution_time = [[ $maxExecutionTime ]]\ndisplay_startup_errors = On\nerror_reporting = E_ALL\ndisplay_errors = On|' /etc/hhvm/php.ini -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD (hhvm --mode daemon -vServer.Type=fastcgi -vServer.Port=[[ .Container.GetFirstLocalPort ]] &) && /bin/bash diff --git a/templates/jackrabbit/Dockerfile b/templates/jackrabbit/Dockerfile index 13fe537..56d7a8f 100644 --- a/templates/jackrabbit/Dockerfile +++ b/templates/jackrabbit/Dockerfile @@ -14,11 +14,11 @@ RUN wget http://archive.apache.org/dist/jackrabbit/2.6.5/jackrabbit-standalone-2 # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] cd /opt/jackrabbit/ \ - && (java -jar jackrabbit-standalone-2.6.5.jar --port [[ .Container.GetFirstLocalPort ]] &) \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - && /bin/bash + && (java -jar jackrabbit-standalone-2.6.5.jar --port [[ .Container.GetFirstLocalPort ]] &) \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /bin/bash [[end]] diff --git a/templates/mysql/Dockerfile b/templates/mysql/Dockerfile index 6032616..279f1f3 100644 --- a/templates/mysql/Dockerfile +++ b/templates/mysql/Dockerfile @@ -17,7 +17,7 @@ RUN chmod +x /root/setup.sh # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ diff --git a/templates/nginx/Dockerfile b/templates/nginx/Dockerfile index dcfc8c7..a503069 100644 --- a/templates/nginx/Dockerfile +++ b/templates/nginx/Dockerfile @@ -16,11 +16,11 @@ RUN chmod +x /root/setup.sh # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ - && (/etc/init.d/nginx start &) \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - && /bin/bash + && (/etc/init.d/nginx start &) \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /bin/bash [[ end ]] diff --git a/templates/nodejs/Dockerfile b/templates/nodejs/Dockerfile index fcd9bab..c723646 100644 --- a/templates/nodejs/Dockerfile +++ b/templates/nodejs/Dockerfile @@ -3,25 +3,21 @@ FROM stackbrew/debian:wheezy [[ updateApt ]] [[ addUserFiles ]] -[[ $version := .Container.GetCustomValue "version" "0.10.20"]] - -# Install nodejs with nvm -RUN git clone https://github.com/creationix/nvm.git /.nvm -RUN /bin/bash -c '. /.nvm/nvm.sh && nvm install v[[ $version ]] && nvm use v[[ $version ]] && nvm alias default v[[ $version ]] && ln -s /.nvm/v[[ $version ]]/bin/node /usr/bin/node && ln -s /.nvm/v[[ $version ]]/bin/npm /usr/bin/npm' +[[ installNodeJS ]] # Install modules [[range (.Container.GetCustomValue "modules")]] - RUN npm install -g [[.]] + RUN npm install -g [[.]] [[end]] ENV NODE_PATH /usr/local/lib/node_modules -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] - [[ if (.Container.HasAfterScript) ]] - CMD [[.Container.AfterScript]] && /bin/bash - [[ else ]] - CMD ["/usr/local/bin/node"] && /bin/bash - [[ end]] + [[ if (.Container.HasAfterScript) ]] + CMD [[.Container.AfterScript]] && /bin/bash + [[ else ]] + CMD ["/usr/local/bin/node"] && /bin/bash + [[ end]] [[ end ]] diff --git a/templates/npm/Dockerfile b/templates/npm/Dockerfile index 10d6a7a..7fd5856 100644 --- a/templates/npm/Dockerfile +++ b/templates/npm/Dockerfile @@ -3,19 +3,14 @@ FROM stackbrew/debian:wheezy [[ updateApt ]] [[ addUserFiles ]] -[[ $version := .Container.GetCustomValue "fastCgi" "0.10.20"]] - -# Install nodejs with nvm -RUN git clone https://github.com/creationix/nvm.git /.nvm -RUN echo "/.nvm/nvm.sh" >> /etc/bash.bashrc -RUN /bin/bash -c '. /.nvm/nvm.sh && nvm install v[[ $version ]] && nvm use v[[ $version ]] && nvm alias default v[[ $version ]] && ln -s /.nvm/v[[ $version ]]/bin/node /usr/bin/node && ln -s /.nvm/v[[ $version ]]/bin/npm /usr/bin/npm' +[[ installNodeJS ]] # Install NPM RUN curl https://www.npmjs.org/install.sh | clean=no sh # Install modules [[range (.Container.GetCustomValue "modules")]] - RUN npm install -g [[.]] + RUN npm install -g [[.]] [[end]] ENV NODE_PATH /usr/local/lib/node_modules diff --git a/templates/php-fpm/Dockerfile b/templates/php-fpm/Dockerfile index adfeef6..f6d3770 100644 --- a/templates/php-fpm/Dockerfile +++ b/templates/php-fpm/Dockerfile @@ -27,11 +27,11 @@ RUN chmod +x /root/setup.sh # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ - && php5-fpm -R \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - && /bin/bash + && php5-fpm -R \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /bin/bash [[ end ]] diff --git a/templates/php-fpm/setup.sh b/templates/php-fpm/setup.sh index 17c5460..c9ff063 100644 --- a/templates/php-fpm/setup.sh +++ b/templates/php-fpm/setup.sh @@ -14,5 +14,5 @@ for env in $envs do IFS== read name value <<< "$env" - echo "env[$name] = $value" >> /etc/php5/fpm/php-fpm.conf + echo "env[$name] = $value" >> /etc/php5/fpm/php-fpm.conf done diff --git a/templates/phpmyadmin/Dockerfile b/templates/phpmyadmin/Dockerfile index 464b007..437a4ed 100644 --- a/templates/phpmyadmin/Dockerfile +++ b/templates/phpmyadmin/Dockerfile @@ -23,7 +23,7 @@ RUN sed -i "s|// \$cfg\['Servers'\]\[\$i\]\['AllowNoPassword'\] = TRUE;|\$cfg\[' ADD setup.sh /root/setup.sh RUN chmod +x /root/setup.sh -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ diff --git a/templates/python/Dockerfile b/templates/python/Dockerfile index 5e74404..e56dcbd 100644 --- a/templates/python/Dockerfile +++ b/templates/python/Dockerfile @@ -16,14 +16,14 @@ ENV PATH /.pyenv/versions/[[ $version ]]/bin:$PATH # Install pip modules [[range (.Container.GetCustomValue "pip_modules")]] - RUN pip install [[.]] + RUN pip install [[.]] [[end]] # Add custom setup script [[ beforeAfterScripts ]] [[ if (.Container.HasAfterScript) ]] - CMD [[.Container.AfterScript]] && /bin/bash + CMD [[.Container.AfterScript]] && /bin/bash [[ else ]] - CMD /bin/bash + CMD /bin/bash [[ end]] diff --git a/templates/ror/000-default b/templates/ror/000-default new file mode 100644 index 0000000..edb00bd --- /dev/null +++ b/templates/ror/000-default @@ -0,0 +1,39 @@ + + ServerAdmin webmaster@localhost + + [[ $version := (.Container.GetCustomValue "version" "2.1.2") ]] + PassengerRuby /usr/local/rvm/gems/ruby-[[ $version ]]/wrappers/ruby + RailsEnv development + + [[ $documentRoot := (.Container.GetCustomValue "documentRoot") ]] + [[ if $documentRoot ]] + DocumentRoot [[ $documentRoot ]] + [[ else ]] + DocumentRoot /var/www + [[ end ]] + + Options FollowSymLinks + AllowOverride None + + + [[ if $documentRoot ]] + + [[ else ]] + + [[ end ]] + + Options Indexes FollowSymLinks MultiViews + AllowOverride All + Order allow,deny + allow from all + + + ErrorLog ${APACHE_LOG_DIR}/error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog ${APACHE_LOG_DIR}/access.log combined + + diff --git a/templates/ror/Dockerfile b/templates/ror/Dockerfile new file mode 100644 index 0000000..67bdb9d --- /dev/null +++ b/templates/ror/Dockerfile @@ -0,0 +1,50 @@ +FROM stackbrew/debian:wheezy + +[[ updateApt ]] +[[ addUserFiles ]] + +[[ $version := (.Container.GetCustomValue "version" "2.1.2") ]] +[[ $serverType := (.Container.GetCustomValue "serverType" "standalone") ]] + +[[ installRvm ]] + +# Install nodejs +[[ .Container.SetCustomValue "nodeVersion" "0.10.20"]] +[[ installNodeJS ]] + +# Install custom gems +[[range (.Container.GetCustomValue "gems")]] + RUN gem install [[.]] +[[end]] + +[[ if eq $serverType "apache"]] + RUN apt-get install -y -f apache2 + RUN a2enmod actions alias + RUN service apache2 reload + + RUN apt-get install -y -f libcurl4-openssl-dev apache2-threaded-dev libapr1-dev libaprutil1-dev + RUN /bin/bash -l -c 'gem install passenger bundler execjs' + RUN /bin/bash -l -c 'passenger-install-apache2-module --auto' + + RUN print "LoadModule passenger_module /usr/local/rvm/gems/ruby-[[ $version ]]/gems/passenger-4.0.44/buildout/apache2/mod_passenger.so \n\nPassengerRoot /usr/local/rvm/gems/ruby-[[ $version ]]/gems/passenger-4.0.44 \nPassengerDefaultRuby /usr/local/rvm/gems/ruby-[[ $version ]]/wrappers/ruby \n" > /etc/apache2/mods-available/passenger.load + RUN a2enmod passenger + + ADD 000-default /etc/apache2/sites-enabled/000-default + ADD ports.conf /etc/apache2/ports.conf +[[ end ]] + +# Add setup script +ADD setup.sh /root/setup.sh +RUN chmod +x /root/setup.sh + +# Add custom setup script +[[ beforeAfterScripts ]] + +[[ if .EmptyCmd ]] +CMD /bin/bash +[[ else ]] +CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /etc/init.d/apache2 start \ + && /bin/bash +[[ end ]] diff --git a/templates/ror/ports.conf b/templates/ror/ports.conf new file mode 100644 index 0000000..ed0aa78 --- /dev/null +++ b/templates/ror/ports.conf @@ -0,0 +1,15 @@ +NameVirtualHost *:[[ .Container.GetFirstLocalPort ]] +Listen [[ .Container.GetFirstLocalPort ]] + + + # If you add NameVirtualHost *:443 here, you will also have to change + # the VirtualHost statement in /etc/apache2/sites-available/default-ssl + # to + # Server Name Indication for SSL named virtual hosts is currently not + # supported by MSIE on Windows XP. + Listen 443 + + + + Listen 443 + diff --git a/templates/ror/setup.sh b/templates/ror/setup.sh new file mode 100644 index 0000000..fed62c4 --- /dev/null +++ b/templates/ror/setup.sh @@ -0,0 +1,21 @@ +[[ $dir := .Container.GetFirstMountedDir ]] +[[ $projectName := .Container.GetCustomValue "project_name" "project" ]] +[[ $version := (.Container.GetCustomValue "version" "1.9.3") ]] + +if [ ! -d "[[$dir]]/[[ $projectName ]]" ]; then + + # Install ror + /bin/bash -l -c 'gem install rails bundler' + cd [[ $dir ]] && /bin/bash -l -c 'rails new [[ $projectName ]] [[ if(.Container.DependsOf "mysql" )]] -d mysql [[ end ]] -T' + + cd [[ $dir ]]/[[ $projectName ]] + printf "gem 'execjs'\ngem 'therubyracer'" >> Gemfile + /bin/bash -l -c 'bundle install' + + [[ if(.Container.DependsOf "mysql") ]] + [[ $db := (.Collection.GetType "mysql")]] + sed -i -e "s/host: localhost/host: <%= ENV['DB_PORT_3306_TCP_ADDR'] %>/" [[ $dir ]]/[[ $projectName ]]/config/database.yml + sed -i -e "s/host: localhost/host: <%= ENV['DB_PORT_3306_TCP_ADDR'] %>/" [[ $dir ]]/[[ $projectName ]]/config/database.yml + /bin/bash -c -l 'rake db:migrate' + [[ end ]] +fi diff --git a/templates/ruby/Dockerfile b/templates/ruby/Dockerfile new file mode 100644 index 0000000..9f9c244 --- /dev/null +++ b/templates/ruby/Dockerfile @@ -0,0 +1,20 @@ +FROM stackbrew/debian:wheezy + +[[ updateApt ]] +[[ addUserFiles ]] + +[[ installRvm ]] + +# Install custom gems +[[range (.Container.GetCustomValue "gems")]] + RUN gem install [[.]] +[[end]] + +# Add custom setup script +[[ beforeAfterScripts ]] + +[[ if (.Container.HasAfterScript) ]] + CMD [[.Container.AfterScript]] && /bin/bash +[[ else ]] + CMD /bin/bash +[[ end]] diff --git a/templates/varnish/Dockerfile b/templates/varnish/Dockerfile index df219ae..b5df525 100644 --- a/templates/varnish/Dockerfile +++ b/templates/varnish/Dockerfile @@ -21,11 +21,11 @@ RUN chmod +x /root/setup.sh # Add custom setup script [[ beforeAfterScripts ]] -[[ if .EmptyCmd]] +[[ if .EmptyCmd ]] CMD /bin/bash [[ else ]] CMD [[ if (.Container.HasBeforeScript) ]] /bin/bash /root/before-setup.sh && [[end]] /bin/bash /root/setup.sh \ - && varnishd -f /etc/varnish/default.vcl -s malloc,100M -a 0.0.0.0:[[ .Container.GetFirstLocalPort ]] \ - [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] - && /bin/bash + && varnishd -f /etc/varnish/default.vcl -s malloc,100M -a 0.0.0.0:[[ .Container.GetFirstLocalPort ]] \ + [[ if (.Container.HasAfterScript) ]] && /bin/bash /root/after-setup.sh \[[end]] + && /bin/bash [[ end ]] diff --git a/templates/varnish/default.vcl b/templates/varnish/default.vcl index 00bfd7a..69e8647 100644 --- a/templates/varnish/default.vcl +++ b/templates/varnish/default.vcl @@ -24,5 +24,5 @@ director loadBalancer round-robin { } sub vcl_recv { - set req.backend = loadBalancer; + set req.backend = loadBalancer; }