From 9470ad44bd663763a6d030fba4e48c47586931ea Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 11 Aug 2016 11:22:20 +1000 Subject: [PATCH] Import build configuration --- .dockerignore | 1 + .gitlab-ci.yml | 32 ++++++++++++++++++++-- .my.cnf | 6 +++++ 10-default.conf | 5 ++++ Dockerfile | 21 +++++++++------ init | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 125 insertions(+), 10 deletions(-) create mode 100644 .dockerignore create mode 100644 .my.cnf create mode 100644 10-default.conf create mode 100755 init diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..26401e8 --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +image*bz2 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cb33c7d..5b5ef68 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,12 +1,40 @@ image: docker:latest +stages: +- test +- build + +variables: + VERSION: php53 + DOCKER_IMAGE: leenooks/lamps + DOCKER_REGISTRY: registry.leenooks.net + DOCKER_HOST: tcp://${DOCKER_REGISTRY}-leenooks-ci-docker:2375 + services: -- docker:dind +- ${DOCKER_REGISTRY}/leenooks/ci-docker:dind before_script: - docker info +- docker version +- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN ${DOCKER_REGISTRY} + +test: + stage: test + script: + - cat /etc/hosts + - env|sort + - docker build -t ${DOCKER_IMAGE}:${VERSION} . + - docker images + only: + - debug build: stage: build script: - - docker build -t leenooks/lamps . + - docker build -t ${DOCKER_IMAGE}:${VERSION} . + - docker tag ${DOCKER_IMAGE}:${VERSION} ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} + - docker push ${DOCKER_REGISTRY}/${DOCKER_IMAGE}:${VERSION} + tags: + - docker + only: + - master diff --git a/.my.cnf b/.my.cnf new file mode 100644 index 0000000..8640f60 --- /dev/null +++ b/.my.cnf @@ -0,0 +1,6 @@ +[mysql] + user=root + password=ln3550ms +[mysqldump] + user=root + password=ln3550ms diff --git a/10-default.conf b/10-default.conf new file mode 100644 index 0000000..e333a94 --- /dev/null +++ b/10-default.conf @@ -0,0 +1,5 @@ + + AllowOverride AuthConfig FileInfo Indexes Limit Options + Options FollowSymLinks + Require all denied + diff --git a/Dockerfile b/Dockerfile index 10a5217..8a29e7b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # NAME leenooks/lamps -# VERSION latest +# VERSION php53 # BUILD docker build -t="leenooks/lamps" . # START docker run -dp 80:80 [-p 443:443 ] -p 2022:22 \ # -e NO_MAIL=TRUE \ @@ -20,14 +20,11 @@ # --restart=always --name=lamp leenooks/hosting $@ # CRON: docker exec -it lamp /usr/sbin/awstats.sh -FROM leenooks/base:latest +FROM registry.leenooks.net/leenooks/base:7 RUN yum -y install epel-release && yum clean all -# RUN yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm && yum clean all && rm -rf /var/tmp/* - # EPEL & Leenooks packages -#RUN yum -y install --enabler remi-php54 \ RUN yum -y install \ httpd \ mariadb-server \ @@ -38,6 +35,7 @@ RUN yum -y install \ php-mysql \ php-pdo \ php-xml \ + php-composer-installers.noarch \ m4 \ opendkim \ sendmail \ @@ -46,7 +44,8 @@ RUN yum -y install \ ln-http \ ln-awstats \ ln-mail-server \ - openssh-server \ + openssh-server \ + git \ && yum clean all COPY .my.cnf /root/ @@ -55,10 +54,16 @@ RUN ln -f /etc/.ln/httpd/conf.d/awstats.conf /etc/httpd/conf.d/awstats.conf && l EXPOSE 80 443 -COPY init /sbin/ - # Starting +COPY init /sbin/ ENTRYPOINT [ "/sbin/init" ] CMD [ "start" ] +RUN composer global require "laravel/installer" +RUN composer require --dev --no-update "xethron/migrations-generator:dev-l5" && \ + composer require --dev --no-update "way/generators:dev-feature/laravel-five-stable" && \ + composer config repositories.repo-name git "git@github.com:jamisonvalenta/Laravel-4-Generators.git" + +RUN useradd -c "Hosting Admin User" -m lamp && su lamp -lc "composer global require laravel/installer" + RUN yum -y install tsmpipe && yum clean all diff --git a/init b/init new file mode 100755 index 0000000..65933a3 --- /dev/null +++ b/init @@ -0,0 +1,70 @@ +#!/bin/bash +set -e + +NO_DB=${NO_DB:-FALSE} +NO_SSH=${NO_SSH:-TRUE} +NO_MAIL=${NO_MAIL:-FALSE} +NO_HTTP=${NO_HTTP:-FALSE} + +NAME="LAMPS" + +function stop { + echo "Stopping ${NAME}" + [ "$NO_MAIL" != "TRUE" ] && kill $(cat /var/run/opendkim.pid) && kill $(cat /var/run/sendmail.pid|head -1) + [ "$NO_SSH" != "TRUE" ] && kill $(cat /var/run/sshd.pid) + [ "$NO_DB" != "TRUE" ] && kill $(cat /var/run/mariadb/mariadb.pid) + [ "$NO_HTTP" != "TRUE" ] && rm -f /var/run/httpd/authdigest_shm.$(cat /var/run/httpd/httpd.pid) && kill $(cat /var/run/httpd/httpd.pid) +} + +trap 'stop' SIGTERM + +if [ "$1" == "start" ]; then + if [ "$NO_MAIL" != "TRUE" ]; then + if [ -z `hostname --domain` ]; then + echo "You must start this container with --hostname= specifying a domain name" + exit 1 + fi + + echo "Starting OpenDKIM..." + [ ! -f /etc/opendkim/keys/default.private ] && /usr/sbin/opendkim-default-keygen + [ -x /usr/sbin/opendkim ] && /usr/sbin/opendkim -x /etc/opendkim.conf -P /var/run/opendkim.pid -f & + echo "Starting Sendmail..." + cd /etc/mail && make && m4 sendmail.mc > sendmail.cf && /usr/sbin/sendmail -q1h -bD & + else + echo "! NOT starting MAIL" + fi + + if [ "$NO_SSH" != "TRUE" ]; then + echo "Starting SSHD..." + getent passwd lamp || useradd -c "Hosting Admin User" -m lamp + [ -x /usr/sbin/sshd-keygen ] && /usr/sbin/sshd-keygen + [ -x /usr/sbin/sshd ] && /usr/sbin/sshd + else + echo "! NOT starting SSH" + fi + + if [ "$NO_DB" != "TRUE" ]; then + echo "Starting Maria DB..." + [ -x /usr/libexec/mariadb-prepare-db-dir ] && /usr/libexec/mariadb-prepare-db-dir + [ -x /usr/bin/mysqld_safe ] && /usr/bin/mysqld_safe --basedir=/usr & + else + echo "! NOT starting DB" + fi + + if [ "$NO_HTTP" != "TRUE" ]; then + if [ -d /etc/awstats ]; then + find /etc/awstats/ -type l | xargs -n 5 rm -f + [ -e /var/www/sites/*/awstats/awstats*conf ] && find /var/www/sites/*/awstats/awstats*conf -type f -exec ln -sf {} /etc/awstats/ \; + fi + echo "Starting HTTP..." + find /etc/httpd/conf.d/ -type l | xargs -n 5 rm -f + find /etc/httpd/sites.d -type f -exec ln -sf {} /etc/httpd/conf.d/ \; + [ -x /usr/sbin/httpd ] && /usr/sbin/httpd -DFOREGROUND & + else + echo "! NOT starting HTTP" + fi + + wait +else + exec $@ +fi