Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11,693 changes: 7,311 additions & 4,382 deletions .drone.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Stable releases: "1.0.0"
# Pre-releases: "1.0.0-alpha.1", "1.0.0-beta.2", "1.0.0-rc.3"
# Master/dev branch: "1.0.0-dev"
VERSION=12.0.0-dev
VERSION=1.2.3-fred.12

DOCKER_IMAGE ?= teleport

Expand Down
4 changes: 2 additions & 2 deletions docker/sshd/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG TELEPORT_TAG
FROM public.ecr.aws/gravitational/teleport:${TELEPORT_TAG}
ARG BASE_IMAGE
FROM $BASE_IMAGE

# Demo ansible, ssh, htop
RUN apt-get update && apt-get install -y ansible ssh inetutils-syslogd htop
Expand Down
5 changes: 3 additions & 2 deletions dronegen/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ func waitForDockerRegistryStep() step {

func verifyValidPromoteRunSteps() []step {
tagStep := verifyTaggedStep()
verifyStep := verifyNotPrereleaseStep()
// verifyStep := verifyNotPrereleaseStep()

return []step{tagStep, verifyStep}
return []step{tagStep}
// return []step{tagStep, verifyStep}
}

func verifyTaggedStep() step {
Expand Down
67 changes: 59 additions & 8 deletions dronegen/container_image_products.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Product struct {
DockerfileTarget string // Optional. Defines a dockerfile target to stop at on build.
SupportedArchs []string // ISAs that the builder should produce
SetupSteps []step // Product-specific, arch agnostic steps that must be ran before building an image.
ArchSetupSteps map[string][]step // Product and arch specific steps that must be ran before building an image.
ArchSetupSteps map[string][]step // Product and arch specific steps that must be ran before building an image. If commands are empty then they are treated as dependent steps.
DockerfileArgBuilder func(arch string) []string // Generator that returns "docker build --arg" strings
ImageBuilder func(repo *ContainerRepo, tag *ImageTag) *Image // Generator that returns an Image struct that defines what "docker build" should produce
}
Expand Down Expand Up @@ -133,12 +133,44 @@ func NewTeleportOperatorProduct(cloneDirectory string) *Product {
}
}

func NewTeleportLabProduct(cloneDirectory string, version *ReleaseVersion, teleport *Product) *Product {
workingDirectory := path.Join(cloneDirectory, "docker", "sshd")
name := "teleport-lab"
downloadURL := fmt.Sprintf(
"https://raw.githubusercontent.com/gravitational/teleport/%s/docker/sshd/Dockerfile",
version.ShellVersion,
)

setupSteps, dockerfilePath := getTeleportLabSetupSteps(name, workingDirectory, downloadURL)

return &Product{
Name: name,
DockerfilePath: dockerfilePath,
WorkingDirectory: workingDirectory,
SupportedArchs: teleport.SupportedArchs,
DockerfileArgBuilder: func(arch string) []string {
return []string{
fmt.Sprintf("BASE_IMAGE=%s", teleport.GetLocalRegistryImage(arch, version).GetShellName()),
}
},
ImageBuilder: func(repo *ContainerRepo, tag *ImageTag) *Image {
return &Image{
Repo: repo,
Name: name,
Tag: tag,
}
},
SetupSteps: setupSteps,
ArchSetupSteps: getTelportLabArchSetupSteps(teleport, version),
}
}

// Builds all the steps required to prepare the pipeline for building Teleport images.
// Returns the setup steps, the path to the downloaded Teleport dockerfile, and the name of the
// AWS profile that can be used to download artifacts from S3.
func getTeleportSetupSteps(productName, workingPath, downloadURL string) ([]step, string, string) {
assumeS3DownloadRoleStep, profileName := assumeS3DownloadRoleStep(productName)
downloadDockerfileStep, dockerfilePath := downloadTeleportDockerfileStep(productName, workingPath, downloadURL)
downloadDockerfileStep, dockerfilePath := downloadDockerfileStep(productName, workingPath, downloadURL)
// Additional setup steps in the future should go here

return []step{assumeS3DownloadRoleStep, downloadDockerfileStep}, dockerfilePath, profileName
Expand Down Expand Up @@ -227,6 +259,24 @@ func buildTeleportDebName(version *ReleaseVersion, arch string, isEnterprise, is
return debName
}

// Builds all the arch-neutral steps required to prepare the pipeline for building Teleport Lab images.
// Returns the setup steps, and the path to the downloaded Teleport Lab dockerfile
func getTeleportLabSetupSteps(productName, workingPath, downloadURL string) ([]step, string) {
downloadDockerfileStep, dockerfilePath := downloadDockerfileStep(productName, workingPath, downloadURL)
// Additional setup steps should go here in the future

return []step{downloadDockerfileStep}, dockerfilePath
}

func getTelportLabArchSetupSteps(teleport *Product, version *ReleaseVersion) map[string][]step {
archSetupSteps := make(map[string][]step, len(teleport.SupportedArchs))
for _, supportedArch := range teleport.SupportedArchs {
archSetupSteps[supportedArch] = []step{{Name: teleport.GetBuildStepName(supportedArch, version)}}
}

return archSetupSteps
}

// Creates a shell loop with a timeout
// commands: commands to run in a loop
// successCommand: should evaluate to shell true (i.e. `[ true ]`) when the loop has succeeded
Expand Down Expand Up @@ -258,14 +308,13 @@ func wrapCommandsInTimeout(commands []string, successCommand string, timeoutSeco
return loopCommands
}

// Generates a step that downloads the Teleport Dockerfile
// Generates a step that downloads a Dockerfile
// Returns the generated step and the path to the downloaded Dockerfile
func downloadTeleportDockerfileStep(productName, workingPath, downloadURL string) (step, string) {
// Enterprise and fips specific dockerfiles should be configured here in the future if needed
func downloadDockerfileStep(productName, workingPath, downloadURL string) (step, string) {
dockerfilePath := path.Join(workingPath, fmt.Sprintf("Dockerfile-%s", productName))

return step{
Name: fmt.Sprintf("Download Teleport Dockerfile to %q for %s", dockerfilePath, productName),
Name: fmt.Sprintf("Download Dockerfile for %s", productName),
Image: "alpine",
Commands: []string{
"apk add curl",
Expand Down Expand Up @@ -343,8 +392,10 @@ func (p *Product) buildSteps(version *ReleaseVersion, parentStepNames []string,
// Collect the name of steps that are required before build, taking into account arch-specific steps
setupStepNames := make([]string, 0)
for _, archSetupStep := range p.ArchSetupSteps[supportedArch] {
archSetupStep.DependsOn = append(archSetupStep.DependsOn, productSetupStepNames...)
steps = append(steps, archSetupStep)
if len(archSetupStep.Commands) > 0 {
archSetupStep.DependsOn = append(archSetupStep.DependsOn, productSetupStepNames...)
steps = append(steps, archSetupStep)
}
setupStepNames = append(setupStepNames, archSetupStep.Name)
}
if len(setupStepNames) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion dronegen/container_images.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func buildContainerImagePipelines() []pipeline {
}

if configureForPRTestingOnly {
triggers = append(triggers, NewTestTrigger(prBranch, branchMajorVersion))
// triggers = append(triggers, NewTestTrigger(prBranch, branchMajorVersion))
}

pipelines := make([]pipeline, 0, len(triggers))
Expand Down
16 changes: 12 additions & 4 deletions dronegen/container_images_release_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,25 @@ func (rv *ReleaseVersion) buildSplitSemverSteps(onlyBuildFullSemver bool) step {
}

func (rv *ReleaseVersion) getProducts(clonedRepoPath string) []*Product {
ossTeleport := NewTeleportProduct(false, false, rv)
teleportProducts := []*Product{
NewTeleportProduct(false, false, rv), // OSS
NewTeleportProduct(true, false, rv), // Enterprise
NewTeleportProduct(true, true, rv), // Enterprise/FIPS
ossTeleport, // OSS
NewTeleportProduct(true, false, rv), // Enterprise
NewTeleportProduct(true, true, rv), // Enterprise/FIPS
}

teleportOperatorProduct := NewTeleportOperatorProduct(clonedRepoPath)

products := make([]*Product, 0, len(teleportProducts)+1)
teleportLabProducts := []*Product{
// If we want to add Enterprise and/or Enterprise/FIPS Teleport Lab support in the future
// it should be configured here
NewTeleportLabProduct(clonedRepoPath, rv, ossTeleport),
}

products := make([]*Product, 0, len(teleportProducts)+1+len(teleportLabProducts))
products = append(products, teleportProducts...)
products = append(products, teleportOperatorProduct)
products = append(products, teleportLabProducts...)

return products
}
Expand Down
18 changes: 16 additions & 2 deletions dronegen/container_images_repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,25 @@ func (cr *ContainerRepo) buildSteps(buildStepDetails []*buildStepOutput, flags *

// Create and push a manifest for each tag, referencing multiple architectures in the manifest
for _, imageTag := range imageTags {
if buildStepDetails[0].Product.Name == "teleport-lab" {
// if cr.Name == "ECR - staging" {
// continue
// }

if cr.Name == "Quay" {
continue
}

// if cr.Name == "ECR - production" {
// continue
// }
}

multiarchImageTag := *imageTag
multiarchImageTag.Arch = ""
manifestImage := buildStepDetails[0].Product.ImageBuilder(cr, &multiarchImageTag)
manifestStepName := cr.createAndPushManifestStep(manifestImage, pushStepNames, pushedImages[imageTag])
steps = append(steps, manifestStepName)
manifestStep := cr.createAndPushManifestStep(manifestImage, pushStepNames, pushedImages[imageTag])
steps = append(steps, manifestStep)
}

return steps
Expand Down
30 changes: 15 additions & 15 deletions dronegen/container_images_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ package main
// * `configureForPRTestingOnly` has been set to false, and `make dronegen` has been reran afterwords

const (
configureForPRTestingOnly bool = false
configureForPRTestingOnly bool = true
testingSecretPrefix string = "TEST_"
testingQuayRegistryOrg string = "" // "fred_heinecke"
testingQuayRegistryOrg string = "fred_heinecke"
testingECRRegistryOrg string = "u8j2q1d9"
testingECRRegion string = "us-east-2"
prBranch string = "" // "fred/multiarch-teleport-actual-container-images"
prBranch string = "fred/multiarch-teleport-lab-container-images"
testingECRDomain string = "278576220453.dkr.ecr.us-east-2.amazonaws.com"
)

Expand All @@ -70,16 +70,16 @@ const (
StagingEcrRegion string = "us-west-2"
)

func NewTestTrigger(triggerBranch, testMajorVersion string) *TriggerInfo {
// baseTrigger := NewTagTrigger(testMajorVersion)
// baseTrigger := NewPromoteTrigger(testMajorVersion)
baseTrigger := NewCronTrigger([]string{testMajorVersion})
baseTrigger.Name = "Test trigger on push"
baseTrigger.Trigger = trigger{
Repo: triggerRef{Include: []string{"gravitational/teleport"}},
Event: triggerRef{Include: []string{"push"}},
Branch: triggerRef{Include: []string{triggerBranch}},
}
// func NewTestTrigger(triggerBranch, testMajorVersion string) *TriggerInfo {
// // baseTrigger := NewTagTrigger(testMajorVersion)
// // baseTrigger := NewPromoteTrigger(testMajorVersion)
// // baseTrigger := NewCronTrigger([]string{testMajorVersion})
// baseTrigger.Name = "Test trigger on push"
// baseTrigger.Trigger = trigger{
// Repo: triggerRef{Include: []string{"gravitational/teleport"}},
// Event: triggerRef{Include: []string{"push"}},
// Branch: triggerRef{Include: []string{triggerBranch}},
// }

return baseTrigger
}
// return baseTrigger
// }