Last active
September 8, 2016 01:26
-
-
Save akira345/137d7ed91c74dda1be1e to your computer and use it in GitHub Desktop.
Jenkins+DockerでPHPユニットテストサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
postgres: | |
image: postgres:9.3 | |
expose: | |
- "5432:5432" | |
environment: | |
POSTGRES_USER: app_pguser | |
POSTGRES_PASSWORD: pg_p@ssW0d | |
POSTGRES_DB: app_db | |
php56: | |
build: . | |
links: | |
- postgres:db | |
command: /bin/bash unittest.sh | |
volumes: | |
- .:/var/www/html/testapp | |
privileged: true | |
working_dir: /var/www/html/testapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#PHP Unitテスト用(php5.6)Dockerファイルサンプル | |
FROM centos:centos6 | |
MAINTAINER Akira345 | |
# Set TimeZone | |
RUN echo 'ZONE="Asia/Tokyo"' > /etc/sysconfig/clock | |
# Yum Repo Setting | |
RUN sed -i -e 's/^#baseurl/baseurl/' /etc/yum.repos.d/CentOS-Base.repo | |
RUN sed -i -e 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-Base.repo | |
RUN sed -i -e 's/mirror\.centos\.org/ftp\.iij\.ad\.jp\/pub\/linux/' /etc/yum.repos.d/CentOS-Base.repo | |
RUN rpm --import http://ftp.iij.ad.jp/pub/linux/centos/RPM-GPG-KEY-CentOS-6 | |
# PHP5.6 install & more apps | |
RUN rpm --import http://ftp.iij.ad.jp/pub/linux/fedora/epel/RPM-GPG-KEY-EPEL-6 | |
RUN rpm -ivh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm | |
RUN rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi | |
RUN rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm | |
RUN sed -i 's/^enabled=1$/enabled=0/g' /etc/yum.repos.d/epel.repo | |
RUN yum clean all | |
RUN yum -y install --enablerepo=remi --enablerepo=remi-php56 git sudo php php-pdo php-mbstring php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof | |
RUN yum -y update | |
# PHP Setting | |
RUN sed -i -e "s|^;date.timezone =.*$|date.timezone = Asia/Tokyo|" /etc/php.ini | |
RUN sed -i -e "s|^memory_limit = 128M|memory_limit = 512M|" /etc/php.ini | |
# Create Work Directory | |
RUN mkdir /var/www/testapp | |
WORKDIR /var/www/testapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# PostgreSQL9.3 クライアントインストール | |
# 古いバージョンを削除 | |
yum -y remove postgresql postgresql-devel postgresql-libs | |
# リポジトリを追加し、インストール | |
rpm -ivh http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm | |
yum -y install postgresql93 php-pgsql --enablerepo=remi | |
# PWなしてPostgreSQLに接続する為の準備 | |
echo $DB_PORT_5432_TCP_ADDR:5432:$DB_ENV_POSTGRES_DB:$DB_ENV_POSTGRES_USER:$DB_ENV_POSTGRES_PASSWORD > /root/.pgpass | |
chmod 600 /root/.pgpass | |
cat create_tables.sql | psql -U $DB_ENV_POSTGRES_USER -h $DB_PORT_5432_TCP_ADDR $DB_ENV_POSTGRES_DB | |
php composer.phar install | |
mkdir -p ./reports | |
php artisan key:generate | |
phpunit --configuration=phpunit.xml --log-junit=reports/unittest.xml --coverage-clover=reports/coverage.xml --coverage-html=reports tests/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment