-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add packer build for centos based container image
Signed-off-by: Madhav Puri <[email protected]>
- Loading branch information
Showing
6 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM centos:7 | ||
|
||
# This Dockerfile is used to build the contiv/centos-systemd image, used by the packer script. | ||
# This is based on the Dockerfile sample here: | ||
# https://github.com/docker-library/docs/tree/master/centos#dockerfile-for-systemd-base-image | ||
MAINTAINER "Madhav Puri" <[email protected]> | ||
|
||
ENV container docker | ||
|
||
RUN (cd /lib/systemd/system/sysinit.target.wants/; \ | ||
for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ | ||
rm -f /lib/systemd/system/multi-user.target.wants/*;\ | ||
rm -f /etc/systemd/system/*.wants/*;\ | ||
rm -f /lib/systemd/system/local-fs.target.wants/*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ | ||
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ | ||
rm -f /lib/systemd/system/basic.target.wants/*;\ | ||
rm -f /lib/systemd/system/anaconda.target.wants/*; | ||
|
||
VOLUME [ "/sys/fs/cgroup" ] | ||
|
||
CMD ["/usr/sbin/init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
all: build start stop | ||
|
||
start: | ||
docker run -it contiv/centos7 /bin/bash | ||
|
||
stop: | ||
docker rm -f contiv/centos7 | ||
|
||
build: | ||
version=$$(cat VERSION) atlas_token="dummy" packer build --only build --force centos.json | ||
|
||
release-build: | ||
version=$$(cat VERSION) atlas_token=${ATLAS_TOKEN} packer build --only release --force centos.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ | ||
"builders": [ | ||
{ | ||
"name": "build", | ||
"type": "docker", | ||
"image": "contiv/centos-systemd:latest", | ||
"pull": true, | ||
"commit": true, | ||
"volumes": { | ||
"/sys/fs/cgroup":"/sys/fs/cgroup:ro", | ||
"/tmp/$(mktemp -d)":"/run" | ||
}, | ||
"run_command": ["--privileged", "-d", "-i", "-t", "{{.Image}}", "/usr/sbin/init"] | ||
}, | ||
{ | ||
"name": "release", | ||
"type": "docker", | ||
"image": "contiv/centos-systemd:latest", | ||
"pull": true, | ||
"commit": true, | ||
"volumes": { | ||
"/sys/fs/cgroup":"/sys/fs/cgroup:ro", | ||
"/tmp/systemdtest":"/run" | ||
}, | ||
"run_command": ["-privileged", "-d", "-i", "-t", "{{.Image}}", "/usr/sbin/init"] | ||
} | ||
], | ||
"post-processors": [[ | ||
{ | ||
"type": "docker-tag", | ||
"repository": "contiv/centos7", | ||
"tag": "{{ user `version` }}", | ||
"only": ["build", "release"] | ||
}, | ||
{ | ||
"type": "docker-push", | ||
"only": ["release"] | ||
} | ||
]], | ||
"provisioners": [ | ||
{ | ||
"type": "shell", | ||
"environment_vars": [ | ||
"http_proxy={{user `http_proxy`}}", | ||
"https_proxy={{user `https_proxy`}}", | ||
"ftp_proxy={{user `ftp_proxy`}}", | ||
"rsync_proxy={{user `rsync_proxy`}}", | ||
"no_proxy={{user `no_proxy`}}" | ||
], | ||
"scripts": [ | ||
"../../centos/script/ansible.sh", | ||
"script/packer.sh" | ||
] | ||
}, | ||
{ | ||
"type": "ansible-local", | ||
"playbook_dir": "../../../vendor/ansible", | ||
"playbook_file": "../../../vendor/ansible/site.yml", | ||
"inventory_groups": "devtest", | ||
"extra_arguments": [ | ||
"--extra-vars", | ||
"'{\"env\":{ \"http_proxy\":\"{{user `http_proxy`}}\", \"https_proxy\":\"{{user `https_proxy`}}\", \"no_proxy\":\"{{user `no_proxy`}}\", \"ftp_proxy\":\"{{user `ftp_proxy`}}\", \"rsync_proxy\":\"{{user `rsync_proxy`}}\" }, \"validate_certs\":\"no\", \"docker_version\":\"1.11.1\"}'", | ||
"--tags", | ||
"prebake-for-dev,prebake-for-test" | ||
] | ||
}, | ||
{ | ||
"type": "shell", | ||
"scripts": [ | ||
"script/post_provision.sh" | ||
] | ||
} | ||
], | ||
"variables": { | ||
"ftp_proxy": "{{env `ftp_proxy`}}", | ||
"http_proxy": "{{env `http_proxy`}}", | ||
"https_proxy": "{{env `https_proxy`}}", | ||
"no_proxy": "{{env `no_proxy`}}", | ||
"rsync_proxy": "{{env `rsync_proxy`}}", | ||
"ssh_password": "vagrant", | ||
"ssh_username": "vagrant", | ||
"atlas_token": "{{ env `atlas_token` }}", | ||
"version": "{{ env `version` }}" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
|
||
rm -f /usr/sbin/packer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
set -xe | ||
|
||
# enable docker for auto-restart, and cleanly shut it down | ||
# before stopping the container | ||
systemctl enable docker | ||
systemctl stop docker | ||
|
||
# cleanup any temp files created as part of provision | ||
rm -rf /tmp/* |