Skip to content

Instantly share code, notes, and snippets.

@thekid
Last active November 10, 2015 23:17
Show Gist options
  • Select an option

  • Save thekid/8e3c2aae5b4159183162 to your computer and use it in GitHub Desktop.

Select an option

Save thekid/8e3c2aae5b4159183162 to your computer and use it in GitHub Desktop.
Experiment with container-based script execution
language: php
script:
- php /composer.phar install --prefer-dist
- curl -L 'https://github.com/xp-framework/xp-runners/releases/download/v5.6.1/setup' | php
- echo "use=vendor/autoload.php" > xp.ini
- echo "[runtime]" >> xp.ini
- echo "date.timezone=Europe/Berlin" >> xp.ini
- ./unittest src/test/config/unittest/core.ini
require 'psych'
config = Psych.load_file('.nessie.yml')
# puts config
# Create script
File.open('nessie.sh', 'w') do |f|
f.puts '#!/bin/sh'
f.puts 'set -e'
f.puts 'cd /tmp'
# Clone
f.puts 'git clone --depth=50 https://github.com/xp-framework/core.git nessie-build'
# Run script
f.puts 'cd nessie-build'
config['script'].each do |command|
f.puts command
end
f.puts "if [ $? = 0 ] ; then echo 'OK' ; else echo 'FAIL' ; fi"
puts "---> Created " + f.path
end
# Create dockerfile
File.open('Dockerfile', 'w') do |f|
f.puts 'FROM debian:jessie'
f.puts
# Base image provides
# - curl
# - git
f.puts 'RUN apt-get -y update && apt-get install -y curl git'
# Variation by language:
# - php = php5-cli + composer
if config['language'] == 'php'
f.puts 'RUN apt-get install -y php5-cli'
f.puts 'RUN curl -sS https://getcomposer.org/installer | php'
end
f.puts
# Command
f.puts 'CMD ["/bin/sh", "/root/nessie.sh"]'
puts "---> Created " + f.path
end
puts "===> Now run `docker build -t " + config['language'] + " . && docker run -v $PWD/nessie.sh:/root/nessie.sh --rm php`"
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.provision "shell", privileged: true, inline: "apt-get update"
config.vm.provision "shell", privileged: true, inline: "apt-get install -y ruby1.9.3"
config.vm.provision "shell", privileged: true, inline: "apt-get install -y curl"
config.vm.provision "shell", privileged: true, inline: "curl -L https://get.docker.com/ | sh"
config.vm.provision "shell", privileged: true, inline: "usermod -aG docker vagrant"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment