Skip to content
This repository was archived by the owner on May 26, 2021. It is now read-only.

Commit

Permalink
Enable the Docker builds via Vagrant.
Browse files Browse the repository at this point in the history
skyzyx committed Jul 11, 2016
1 parent e7811e5 commit e4d4e47
Showing 5 changed files with 16 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.DS_Store
builds/*.box
builds/
http/
output-parallels-iso/
output-virtualbox-iso/
14 changes: 5 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -45,6 +45,8 @@ You have two choices for installing Packer.

1. Otherwise, you can manually install it from <https://www.packer.io/downloads.html>.

See “[Install Packer](https://www.packer.io/intro/getting-started/setup.html)” for more information.

## Building Vagrant Boxes

### Build everything
@@ -72,20 +74,14 @@ packer build --only=parallels-iso template.json

## Building the Docker Image

1. Boot-up a Vagrant VM.
1. Boot-up a Vagrant VM. This will automatically kick-off the Packer build for Docker.

```bash
vagrant up
```

2. Log into the VM.

```bash
vagrant ssh
```

3. Run Packer from inside the VM to build the Docker image.
2. Once it's done, terminate the Vagrant environment.

```bash
packer build template-docker.json
vagrant destroy
```
8 changes: 8 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@ Vagrant.configure("2") do | config |

# Box
config.vm.box = "skyzyx/centos7"
config.vm.box_url = "file://./builds/centos7-x64-virtualbox.box"
config.vm.boot_timeout = 120

# Check for vbguest plugin
@@ -52,4 +53,11 @@ Vagrant.configure("2") do | config |
end

config.vm.provision :shell, inline: "yum -y install docker-engine"
config.vm.provision :shell, inline: "systemctl enable docker.service"
config.vm.provision :shell, inline: "systemctl start docker.service"
config.vm.provision :shell, inline: "wget -O /tmp/packer.zip https://releases.hashicorp.com/packer/0.10.1/packer_0.10.1_linux_amd64.zip"
config.vm.provision :shell, inline: "unzip -o -d /usr/local/bin/ /tmp/packer.zip"
config.vm.provision :shell, inline: "ln -fs /usr/local/bin/packer /usr/local/bin/packer-io"
config.vm.provision :shell, inline: "groupmems -g docker -a vagrant"
config.vm.provision :shell, inline: "cd /vagrant && packer-io build template-docker.json"
end
4 changes: 2 additions & 2 deletions template-docker.json
Original file line number Diff line number Diff line change
@@ -3,13 +3,13 @@
{
"type": "docker",
"image": "centos:7.2.1511",
"export_path": "builds/centos7-x64-{{.Provider}}.tar"
"export_path": "builds/centos7-x64-docker.tar"
}
],
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant' | sudo -S sh '{{.Path}}'",
"execute_command": "echo 'vagrant' | sh '{{.Path}}'",
"override": {
"docker": {
"scripts": [
17 changes: 0 additions & 17 deletions template.json
Original file line number Diff line number Diff line change
@@ -70,23 +70,6 @@
["set", "{{.Name}}", "--memsize", "512"],
["set", "{{.Name}}", "--cpus", "1"]
]
},
{
"type": "qemu",
"boot_command": [
"<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
],
"boot_wait": "10s",
"disk_size": 20480,
"http_directory": "http",
"iso_url": "http://mirrors.kernel.org/centos/7.2.1511/isos/x86_64/CentOS-7-x86_64-Minimal-1511.iso",
"iso_checksum": "f90e4d28fa377669b2db16cbcb451fcb9a89d2460e3645993e30e137ac37d284",
"iso_checksum_type": "sha256",
"ssh_username": "vagrant",
"ssh_password": "vagrant",
"ssh_port": 22,
"ssh_wait_timeout": "10000s",
"shutdown_command": "history -c; echo '/sbin/halt -h -p' > /tmp/shutdown.sh; echo 'vagrant' | sudo -S sh '/tmp/shutdown.sh'"
}
],
"provisioners": [

0 comments on commit e4d4e47

Please sign in to comment.