Skip to content

Commit

Permalink
Add sftp/ssh example
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathonsim committed Jan 15, 2018
1 parent 1859aab commit 6812e92
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 4 deletions.
95 changes: 95 additions & 0 deletions buildspec-4-sftpdeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
version: 0.2
phases:
install:
commands:
#This file configures apt to remove it's cache after installs - we want this cache, so we remove this config
- rm -f /etc/apt/apt.conf.d/docker-clean

#Install required packages
- |
export DEBIAN_FRONTEND=noninteractive
#Install php7.1
apt-get update
apt-get install -y software-properties-common
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
apt-get update
# Install PHP 7.1. The ondrej/php repository also contains other versions of php, try just changing the version number
apt-get install -y php7.1\
php7.1-ldap \
php7.1-xml \
php7.1-xmlrpc \
php7.1-zip \
php7.1-mysql \
php7.1-mbstring \
php7.1-mcrypt \
php7.1-gd \
php7.1-readline \
php7.1-opcache \
php7.1-xdebug \
php7.1-dom \
php-xdebug \
php7.1-curl \
unzip
#Enable xdebug - phpunit uses this for code coverage
phpenmod xdebug
# Install MySQL (do you need it? If not, delete this)
apt-get install -y mysql-server
#Install composer
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php ;
php -r "unlink('composer-setup.php');" ;
mv composer.phar /usr/local/bin/composer
#Various handy node based dev tools - do you need these during your build? Comment if not.
#npm install -g gulp
#npm install -g grunt
#npm install -g webpack
# Start Mysql if you need it
- su mysql -s /bin/bash -c "/usr/sbin/mysqld" &

build:
commands:
- echo Build started on `date`
- echo Installing composer deps
- composer install --no-progress --no-suggest

post_build:
commands:
- echo Build completed on `date`

# Create a mysql database
# Do you need to do this? In many cases phpunit will use sqllite or similar to avoid the need for a real DB.
# If you don't need it delete it
- /usr/bin/mysql -u root -e "GRANT ALL ON *.* TO 'test'@'localhost' IDENTIFIED BY '' WITH GRANT OPTION"
- mysqladmin -u test create test

# Run your tests
- ./vendor/bin/phpunit --coverage-html coverage

- aws s3 sync --delete coverage/ "s3://${COVERAGE_S3_BUCKET}/coverage"

# Deployment to the SFTP server
- echo $SSH_KEY > ~/.ssh/id_rsa
- echo $SSH_KEY
- scp -p ${SFTP_PORT} -r build/ ${SSH_USERNAME}@${SSH_SERVER}:/public_html
- ssh ${SSH_USERNAME}@${SSH_SERVER} -p ${SFTP_PORT} rm -f .cache



cache:
paths:
#Debian package caches, so we don't need to keep redownloading debian packages:
- /var/cache/apt/**/*

# Composer cache:
- /root/.composer/**/*

# Node modules, if you need nodejs based tools like webpack during your build
- /root/.npm/**/*
- /usr/lib/node_modules/**/*
8 changes: 4 additions & 4 deletions buildspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ phases:
mv composer.phar /usr/local/bin/composer
#Various handy node based dev tools - do you need these during your build? Comment if not.
npm install -g gulp
npm install -g grunt
npm install -g bower
npm install -g webpack
#npm install -g gulp
#npm install -g grunt
#npm install -g webpack
- su mysql -s /bin/bash -c "/usr/sbin/mysqld" &
build:
commands:
Expand Down

0 comments on commit 6812e92

Please sign in to comment.