Skip to content

Instantly share code, notes, and snippets.

@Fuxy22
Created January 7, 2016 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fuxy22/b3c4fec85cad87c6de01 to your computer and use it in GitHub Desktop.
Save Fuxy22/b3c4fec85cad87c6de01 to your computer and use it in GitHub Desktop.
Gitlab CI docker images and settings for laravel
image: php56
cache:
paths:
- vendor/
- node_modules/
before_script:
- service mysql start
- service apache2 start
- mysql -u root < "database/foxcart.sql"
- echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD('$MYSQL_ROOT_PASS');" | mysql -u root
- composer config -g github-oauth.github.com $GITHUB_OAUTH
- composer install --prefer-dist --no-progress
- cp .env.example .env
- php artisan key:generate
- php artisan migrate:refresh --seed
- npm install --global gulp
- npm install
- gulp
stages:
- test
test:
script:
- serve.sh test.foxcart.io $CI_PROJECT_DIR/public
- echo "$(awk 'NR==1 {print $1}' /etc/hosts) test.foxcart.io" >> /etc/hosts
- vendor/bin/phpunit
- php artisan migrate:reset
FROM ubuntu
RUN apt-get update -y
RUN apt-get install apache2 make build-essential -y
RUN apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql curl wget git -y
RUN apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl -y
COPY serve.sh /usr/bin/
RUN apt-get install ruby1.9.1-dev libsqlite3-dev -y
RUN gem install mailcatcher
RUN export DEBIAN_FRONTEND=noninteractive
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir="/usr/bin" --filename="composer"
RUN a2dissite 000-default
RUN curl -sL https://deb.nodesource.com/setup_5.x | sudo bash -
RUN apt-get install nodejs python -y
EXPOSE 22 80
CMD ["/usr/sbin/apache2ctl -D FOREGROUND"]
#!/usr/bin/env bash
if which nginx > /dev/null 2>&1; then
block="server {
client_max_body_size 100M;
listen 80;
server_name $1;
root $2;
index index.html index.htm index.php;
charset utf-8;
location ~/api/media/(.*) {
root /app;
}
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/$1-error.log error;
error_page 404 /index.php;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
# include fastcgi_params;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
"
echo "$block" > "/etc/nginx/sites-available/$1"
ln -fs "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
service nginx restart
service php5-fpm restart
fi
if which apache2 > /dev/null 2>&1; then
block="<VirtualHost *:80>
ServerName $1
DocumentRoot $2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /builds/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory $2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/$1_error.log
LogLevel warn rewrite:trace2
CustomLog ${APACHE_LOG_DIR}/$1_access.log combined
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName $1
DocumentRoot $2
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /builds/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
<Directory $2>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
ErrorLog ${APACHE_LOG_DIR}/$1_SSL_error.log
LogLevel warn rewrite:trace2
CustomLog ${APACHE_LOG_DIR}/$1_SSL_access.log combined
SSLEngine on
</VirtualHost>
</IfModule>
"
echo "$block" > "/etc/apache2/sites-available/$1.conf"
a2ensite $1
a2enmod rewrite
service apache2 restart
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment