chore(*): build AMI (#83)
This commit is contained in:
parent
7b3092b1e0
commit
1c15d9b12a
@ -23,10 +23,16 @@ policies:
|
||||
script:
|
||||
template: |
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
cd tools && conform enforce
|
||||
cd ../kernel && conform enforce
|
||||
cd ../initramfs && conform enforce
|
||||
cd ../rootfs && conform enforce
|
||||
cd ../generate && conform enforce
|
||||
cd ../
|
||||
|
||||
{{ if or (and .Git.IsClean .Git.IsTag) (and .Git.IsClean (eq .Git.Branch "master")) }}
|
||||
packer build -var 'version={{ .Docker.Image.Tag }}' packer.json
|
||||
{{ end }}
|
||||
|
@ -24,9 +24,9 @@ EOF
|
||||
function raw() {
|
||||
dd if=/dev/zero of=/dianemo.raw bs=1M count=$(($(size) + 150))
|
||||
parted -s /dianemo.raw mklabel gpt
|
||||
parted -s -a none /dianemo.raw mkpart ESP fat32 0 50M
|
||||
parted -s -a none /dianemo.raw mkpart ROOT xfs 50M $(($(size) + 100))M
|
||||
parted -s -a none /dianemo.raw mkpart DATA xfs $(($(size) + 100))M $(($(size) + 150))M
|
||||
parted -s -a optimal /dianemo.raw mkpart ESP fat32 0 50M
|
||||
parted -s -a optimal /dianemo.raw mkpart ROOT xfs 50M $(($(size) + 100))M
|
||||
parted -s -a optimal /dianemo.raw mkpart DATA xfs $(($(size) + 100))M 100%
|
||||
losetup /dev/loop0 /dianemo.raw
|
||||
partx -av /dev/loop0
|
||||
sgdisk /dev/loop0 --attributes=1:set:2
|
||||
@ -42,7 +42,7 @@ DEFAULT Dianemo
|
||||
LABEL Dianemo
|
||||
KERNEL /boot/vmlinuz
|
||||
INITRD /boot/initramfs.xz
|
||||
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=/dev/xvda
|
||||
APPEND ip=dhcp consoleblank=0 console=tty0 console=ttyS0,9600 dianemo.autonomy.io/root=/dev/xvda dianemo.autonomy.io/userdata=http://169.254.169.254/latest/user-data
|
||||
EOF
|
||||
cp -v /rootfs/boot/* /mnt/boot
|
||||
umount /mnt
|
||||
@ -62,8 +62,8 @@ EOF
|
||||
function rootfs() {
|
||||
dd if=/dev/zero of=/rootfs.raw bs=1M count=$(($(size) + 100))
|
||||
parted -s /rootfs.raw mklabel gpt
|
||||
parted -s -a none /rootfs.raw mkpart ROOT xfs 0 $(($(size) + 50))M
|
||||
parted -s -a none /rootfs.raw mkpart DATA xfs $(($(size) + 50))M $(($(size) + 100))M
|
||||
parted -s -a optimal /rootfs.raw mkpart ROOT xfs 0 $(($(size) + 50))M
|
||||
parted -s -a optimal /rootfs.raw mkpart DATA xfs $(($(size) + 50))M 100%
|
||||
losetup /dev/loop0 /rootfs.raw
|
||||
partx -av /dev/loop0
|
||||
mkfs.xfs -n ftype=1 -L ROOT /dev/loop0p1
|
||||
|
79
packer.json
Normal file
79
packer.json
Normal file
@ -0,0 +1,79 @@
|
||||
{
|
||||
"variables": {
|
||||
"built": "{{ isotime }}"
|
||||
},
|
||||
"builders": [
|
||||
{
|
||||
"type": "amazon-ebssurrogate",
|
||||
"region": "{{ user `region` }}",
|
||||
"spot_price_auto_product": "Linux/UNIX (Amazon VPC)",
|
||||
"ssh_pty": true,
|
||||
"instance_type": "t2.small",
|
||||
"associate_public_ip_address": true,
|
||||
"ssh_username": "ubuntu",
|
||||
"ssh_timeout": "5m",
|
||||
"source_ami_filter": {
|
||||
"filters": {
|
||||
"virtualization-type": "hvm",
|
||||
"name": "*ubuntu-yakkety-16.10-amd64-server-*",
|
||||
"root-device-type": "ebs"
|
||||
},
|
||||
"owners": [
|
||||
"099720109477"
|
||||
],
|
||||
"most_recent": true
|
||||
},
|
||||
"launch_block_device_mappings": [
|
||||
{
|
||||
"device_name": "/dev/xvdf",
|
||||
"delete_on_termination": true,
|
||||
"volume_size": 8,
|
||||
"volume_type": "gp2"
|
||||
}
|
||||
],
|
||||
"run_tags": {
|
||||
"Name": "Packer - Dianemo {{ user `version` }}"
|
||||
},
|
||||
"run_volume_tags": {
|
||||
"Name": "Packer - Dianemo {{ user `version` }}"
|
||||
},
|
||||
"ami_name": "dianemo-amd64-hvm-{{ user `version` }}",
|
||||
"ami_description": "Dianemo (HVM)",
|
||||
"ami_virtualization_type": "hvm",
|
||||
"ami_regions": [
|
||||
"us-west-1",
|
||||
"us-west-2",
|
||||
"us-east-1",
|
||||
"us-east-2"
|
||||
],
|
||||
"ami_root_device": {
|
||||
"source_device_name": "/dev/xvdf",
|
||||
"device_name": "/dev/xvda",
|
||||
"delete_on_termination": true,
|
||||
"volume_size": 8,
|
||||
"volume_type": "gp2"
|
||||
},
|
||||
"tags": {
|
||||
"Name": "Dianemo {{ user `version` }}",
|
||||
"Built": "{{ user `built` }}"
|
||||
}
|
||||
}
|
||||
],
|
||||
"provisioners": [
|
||||
{
|
||||
"type": "file",
|
||||
"source": "build/dianemo.raw",
|
||||
"destination": "/tmp/dianemo.raw"
|
||||
},
|
||||
{
|
||||
"type": "shell",
|
||||
"inline": [
|
||||
"sudo dd if=/tmp/dianemo.raw of=/dev/xvdf",
|
||||
"echo -n 'Fix\n3\n100%\n' | sudo parted /dev/xvdf ---pretend-input-tty unit % resizepart",
|
||||
"sudo mount /dev/xvdf3 /mnt",
|
||||
"sudo xfs_growfs -d /dev/xvdf3",
|
||||
"sudo umount /mnt"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user