Last active
August 3, 2021 22:19
-
-
Save boblechat/d667a3e2f5f227162aa31bd323de3b09 to your computer and use it in GitHub Desktop.
Packer base image
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
source "docker" "alm" { | |
image = "alm/base:20.04" | |
pull = false # cause we previously built it | |
commit = true | |
} | |
build { | |
name = "agent" | |
source "sources.docker.alm" { | |
changes = [] | |
# that f*ckin' line which was supposed to be set to true BY DEFAULT | |
# uncomment to make it work | |
# fix_upload_owner = true | |
} | |
provisioner "shell" { | |
inline = [ | |
"echo Hello from Hell!" | |
] | |
execute_command = "sudo sh -c '{{ .Vars }} {{ .Path }}'" | |
} | |
post-processor "docker-tag" { | |
repository = "alm/agent" | |
tags = [ "20.04" ] | |
} | |
} |
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
source "docker" "base" { | |
image = "ubuntu:20.04" | |
pull = false # already in cache | |
commit = true | |
} | |
build { | |
name = "base" | |
source "sources.docker.base" { | |
changes = [ | |
"USER johndoe" # run our 'base' image as johndoe | |
] | |
} | |
provisioner "shell" { | |
inline = [ "apt-get update && apt-get install sudo -y" ] # cause sudo isn't in the base image. shame... | |
} | |
provisioner "shell" { | |
inline = [ | |
"echo Hello from base!", | |
"groupadd -g 666 johndoe", # create johndoe group | |
"useradd -r -m -u 666 -g 666 -G sudo johndoe && passwd -d johndoe", # create passwordless, sudoer user johndoe in the johndoe group | |
] | |
} | |
post-processor "docker-tag" { | |
repository = "alm/base" | |
tags = [ "20.04" ] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment