scalable is
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..c124898
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,33 @@
+
+FROM ubuntu:14.04
+MAINTAINER Takashi Masuda
+
+RUN apt-get update && \
+ apt-get install -y curl openssh-server rsync && \
+ apt-get clean && \
+
+ # SSHD
+ mkdir /var/run/sshd && \
+ sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/' \
+ -e 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config && \
+
+ # Create /root/.ssh/authorized_keys
+ mkdir -p /root/.ssh && \
+ echo ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDXDZmjpkxKwjFBec3v1S9vHpEAmgT7k5A8iLlhUtRGVvgADLgoblHgNitCg8qoDLDeRX0iY+smjChP1n0LBEaSZR+9G6J6/HPg3GHBaSDCpZK1sajTamGBPLokTDStdejJQPyh7ZZUxyN8RzOmH1Eu2FggCI+y/b60KxQnJorG5fxfhy4faFuzdUmEN+yaJu7U5pCQcsNhDqOKCpfiBm2Of1oPby4VybIXvF4TgkpJJ7JwmCIG62X5ldSh86lmKWQdJanelmz/GkJ+2CtSuKjIQuFajz1nBcNZzjPXSBYA+qDCT0mNQNvtgyDZjDZ4ALpkhzjeqHnd+esuulo1o8fJ ci-docker > /root/.ssh/authorized_keys && \
+ chmod 600 /root/.ssh/authorized_keys && \
+
+ # SSH login fix. Otherwise user is kicked off after login
+ sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \
+
+ # Install Chef Client
+ # See also https://docs.chef.io/install_omnibus.html
+ CHEF_VERSION=12.4.1 && \
+ curl -L https://www.chef.io/chef/install.sh | bash -s -- -v $CHEF_VERSION && \
+
+ # Use in site-cookbooks
+ echo PermitUserEnvironment yes >> /etc/ssh/sshd_config && \
+ echo DOCKER_IN_CIRCLECI=true > /root/.ssh/environment
+
+EXPOSE 22
+CMD ["/usr/sbin/sshd", "-D"]
diff --git a/circle.yml b/circle.yml
index 8b1eb47..957be6a 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,7 +1,10 @@
+machine:
+ services:
+ - docker
+
dependencies:
cache_directories:
- - ~/.vagrant.d
- - ~/tmp
+ - ~/cache
pre:
- |
gem update bundler --no-document
@@ -10,19 +13,7 @@ dependencies:
exit 0
fi
- VERSION=1.7.4
-
- mkdir -p ~/tmp
- cd ~/tmp
-
- if [ ! -f vagrant_${VERSION}_x86_64.deb ]; then
- wget https://dl.bintray.com/mitchellh/vagrant/vagrant_${VERSION}_x86_64.deb
- fi
- sudo dpkg -i vagrant_${VERSION}_x86_64.deb
-
- if ! vagrant plugin list | fgrep -q vagrant-aws; then
- vagrant plugin install vagrant-aws
- fi
+ ./script/bootstrap-docker.sh
test:
pre:
@@ -30,21 +21,18 @@ test:
if [ -n "${BUNDLE_UPDATE}" ]; then
exit 0
fi
- vagrant up ec2
- vagrant ssh-config --host=ec2 ec2 >> ~/.ssh/config
- bundle exec knife solo bootstrap ec2
+
+ bundle exec knife solo cook ci-docker
+
+ # workaround
+ ssh ci-docker "/etc/init.d/mongodb start && /etc/init.d/td-agent start"
override:
- |
if [ -n "${BUNDLE_UPDATE}" ]; then
exit 0
fi
- bundle exec rake spec:ec2
- post:
- - |
- if [ -n "${BUNDLE_UPDATE}" ]; then
- exit 0
- fi
- vagrant destroy -f ec2
+
+ bundle exec rake spec:ci:docker
deployment:
production:
diff --git a/nodes/ec2.json b/nodes/ci-docker.json
similarity index 100%
rename from nodes/ec2.json
rename to nodes/ci-docker.json
diff --git a/script/bootstrap-docker.sh b/script/bootstrap-docker.sh
new file mode 100755
index 0000000..b250160
--- /dev/null
+++ b/script/bootstrap-docker.sh
@@ -0,0 +1,36 @@
+#!/bin/sh -xe
+
+cat <> $HOME/.ssh/config
+Host ci-docker
+ HostName 127.0.0.1
+ User root
+ Port 40022
+ UserKnownHostsFile /dev/null
+ StrictHostKeyChecking no
+ PasswordAuthentication no
+ IdentityFile ~/.ssh/id_ci-docker
+ IdentitiesOnly yes
+ LogLevel FATAL
+EOF
+
+chmod 600 $HOME/.ssh/config
+
+docker_archive=$HOME/cache/ubuntu.tar.gz
+md5_digest_file=$HOME/cache/Dockerfile.digest
+
+cache_is_available() {
+ md5sum --status --quiet --check $md5_digest_file > /dev/null 2>&1
+}
+
+if cache_is_available; then
+ docker load < $docker_archive
+else
+ mkdir -p $HOME/cache
+ docker build -t docker/ubuntu .
+ md5sum $HOME/$CIRCLE_PROJECT_REPONAME/Dockerfile > $md5_digest_file
+ docker save docker/ubuntu | gzip -c > $docker_archive
+fi
+
+docker info
+
+docker run -d --privileged -p 40022:22 docker/ubuntu
diff --git a/site-cookbooks/hostname/recipes/default.rb b/site-cookbooks/hostname/recipes/default.rb
index 3525de7..9c25938 100644
--- a/site-cookbooks/hostname/recipes/default.rb
+++ b/site-cookbooks/hostname/recipes/default.rb
@@ -15,4 +15,5 @@ end
file '/etc/hostname' do
content "#{fqdn}\n"
+ atomic_update false
end
diff --git a/site-cookbooks/jdk/recipes/default.rb b/site-cookbooks/jdk/recipes/default.rb
index 8a04f0a..f04839c 100644
--- a/site-cookbooks/jdk/recipes/default.rb
+++ b/site-cookbooks/jdk/recipes/default.rb
@@ -7,4 +7,7 @@
# All rights reserved - Do Not Redistribute
#
-package 'openjdk-7-jdk'
+package 'openjdk-7-jdk' do
+ options '--no-install-recommends' if ENV['DOCKER_IN_CIRCLECI']
+end
diff --git a/site-cookbooks/ufw/recipes/default.rb b/site-cookbooks/ufw/recipes/default.rb
index 6a0f2e7..289dcc6 100644
--- a/site-cookbooks/ufw/recipes/default.rb
+++ b/site-cookbooks/ufw/recipes/default.rb
@@ -7,6 +7,8 @@
# All rights reserved - Do Not Redistribute
#
+return if ENV['DOCKER_IN_CIRCLECI']
+
execute 'ufw reload' do
action :nothing
end
diff --git a/spec/role/ci_spec.rb b/spec/role/ci_spec.rb
index 5a091d7..d8798a8 100644
--- a/spec/role/ci_spec.rb
+++ b/spec/role/ci_spec.rb
@@ -27,7 +27,6 @@ describe 'prod' do
it_behaves_like 'sysstat'
it_behaves_like 'td-agent'
it_behaves_like 'timezone'
- it_behaves_like 'ufw'
it_behaves_like 'user'
it_behaves_like 'zsh'
end
diff --git a/tasks/spec.rake b/tasks/spec.rake
index 120ff7f..f4265f6 100644
--- a/tasks/spec.rake
+++ b/tasks/spec.rake
@@ -7,8 +7,8 @@ hosts = [
role: 'prod',
},
{
- name: 'ec2',
- short_name: 'ec2',
+ name: 'ci-docker',
+ short_name: 'ci:docker',
role: 'ci',
},
{
No comments:
Post a Comment