-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Drone publishing for Amazon ECR #14347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
a90a541
Update Makefile Image names
logand22 544c127
Update drone tagging for ECR staging registry
logand22 cbb5d7f
Update promotion pipeline to push to both registries
logand22 112c2d8
Update cronjob step to publish to both places.
logand22 aeda0d3
Fix _ to - in Makefile
logand22 e15ec22
Updated image names
logand22 62bedf8
Added Registry variables
logand22 5d8db4b
Incorporate additional feedback.
logand22 91ce403
Update environment secret names
logand22 732666e
Added promotion step to cronjob for ecr
logand22 9655a5c
Removed unneeded docker pull
logand22 8b03509
Fix cronjob issue
logand22 e42b557
Add docker service
logand22 c28d118
Update staging image to use hour and minutes
logand22 5c20f6e
Fix typo
logand22 12d73c6
Fix v8 download for non-ecr
logand22 64dde1d
Updated drone signature
logand22 59a0cc3
Lint updates
logand22 4a5d66d
Update commit for e
logand22 7af4c48
Migrate code to new file.
logand22 224492a
Add license for linting.
logand22 4ed109a
Merge branch 'master' into logan/update-drone-publishing
logand22 9559b02
Merge branch 'master' into logan/update-drone-publishing
logand22 01d19b1
Merge branch 'master' into logan/update-drone-publishing
logand22 a19a962
Update signature
logand22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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,133 @@ | ||
| // Copyright 2021 Gravitational, Inc | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func promoteBuildPipelines() []pipeline { | ||
| aptPipeline := promoteAptPipeline() | ||
| dockerPipelineECR := buildDockerPromotionPipelineECR() | ||
| dockerPipelineQuay := buildDockerPromotionPipelineQuay() | ||
| return []pipeline{aptPipeline, dockerPipelineECR, dockerPipelineQuay} | ||
| } | ||
|
|
||
| func buildDockerPromotionPipelineECR() pipeline { | ||
| dockerPipeline := newKubePipeline("promote-docker-ecr") | ||
| dockerPipeline.Trigger = triggerPromote | ||
| dockerPipeline.Trigger.Target.Include = append(dockerPipeline.Trigger.Target.Include, "promote-docker", "promote-docker-ecr") | ||
| dockerPipeline.Workspace = workspace{Path: "/go"} | ||
|
|
||
| // Add docker service | ||
| dockerPipeline.Services = []service{ | ||
| dockerService(), | ||
| } | ||
| dockerPipeline.Volumes = dockerVolumes() | ||
|
|
||
| dockerPipeline.Steps = append(dockerPipeline.Steps, verifyTaggedBuildStep()) | ||
| dockerPipeline.Steps = append(dockerPipeline.Steps, waitForDockerStep()) | ||
|
|
||
| // Pull/Push Steps | ||
| dockerPipeline.Steps = append(dockerPipeline.Steps, step{ | ||
| Name: "Pull/retag Docker images", | ||
| Image: "docker", | ||
| Environment: map[string]value{ | ||
| "AWS_ACCESS_KEY_ID": {fromSecret: "PRODUCTION_TELEPORT_DRONE_USER_ECR_KEY"}, | ||
| "AWS_SECRET_ACCESS_KEY": {fromSecret: "PRODUCTION_TELEPORT_DRONE_USER_ECR_SECRET"}, | ||
| }, | ||
| Volumes: dockerVolumeRefs(), | ||
| Commands: []string{ | ||
| "apk add --no-cache aws-cli", | ||
| "export VERSION=${DRONE_TAG##v}", | ||
| // authenticate with staging credentials | ||
| "aws ecr get-login-password --region=us-west-2 | docker login -u=\"AWS\" --password-stdin " + StagingRegistry, | ||
| // pull staging images | ||
| "echo \"---> Pulling images for $${VERSION}\"", | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport:$${VERSION}", StagingRegistry), | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport-ent:$${VERSION}", StagingRegistry), | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport-ent:$${VERSION}-fips", StagingRegistry), | ||
| // retag images to production naming | ||
| "echo \"---> Tagging images for $${VERSION}\"", | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport:$${VERSION} %s/gravitational/teleport:$${VERSION}", StagingRegistry, ProductionRegistry), | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport-ent:$${VERSION} %s/gravitational/teleport-ent:$${VERSION}", StagingRegistry, ProductionRegistry), | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport-ent:$${VERSION}-fips %s/gravitational/teleport-ent:$${VERSION}-fips", StagingRegistry, ProductionRegistry), | ||
| // authenticate with production credentials | ||
| "docker logout " + StagingRegistry, | ||
| "aws ecr-public get-login-password --region=us-east-1 | docker login -u=\"AWS\" --password-stdin " + ProductionRegistry, | ||
| // push production images | ||
| "echo \"---> Pushing images for $${VERSION}\"", | ||
| // push production images ECR | ||
| fmt.Sprintf("docker push %s/gravitational/teleport:$${VERSION}", ProductionRegistry), | ||
| fmt.Sprintf("docker push %s/gravitational/teleport-ent:$${VERSION}", ProductionRegistry), | ||
| fmt.Sprintf("docker push %s/gravitational/teleport-ent:$${VERSION}-fips", ProductionRegistry), | ||
| }, | ||
| }) | ||
|
|
||
| return dockerPipeline | ||
| } | ||
|
|
||
| func buildDockerPromotionPipelineQuay() pipeline { | ||
| dockerPipeline := newKubePipeline("promote-docker-quay") | ||
| dockerPipeline.Trigger = triggerPromote | ||
| dockerPipeline.Trigger.Target.Include = append(dockerPipeline.Trigger.Target.Include, "promote-docker", "promote-docker-quay") | ||
| dockerPipeline.Workspace = workspace{Path: "/go"} | ||
|
|
||
| // Add docker service | ||
| dockerPipeline.Services = []service{ | ||
| dockerService(), | ||
| } | ||
| dockerPipeline.Volumes = dockerVolumes() | ||
|
|
||
| dockerPipeline.Steps = append(dockerPipeline.Steps, verifyTaggedBuildStep()) | ||
| dockerPipeline.Steps = append(dockerPipeline.Steps, waitForDockerStep()) | ||
|
|
||
| // Pull/Push Steps | ||
| dockerPipeline.Steps = append(dockerPipeline.Steps, step{ | ||
| Name: "Pull/retag Docker images", | ||
| Image: "docker", | ||
| Environment: map[string]value{ | ||
| "AWS_ACCESS_KEY_ID": {fromSecret: "STAGING_TELEPORT_DRONE_USER_ECR_KEY"}, | ||
| "AWS_SECRET_ACCESS_KEY": {fromSecret: "STAGING_TELEPORT_DRONE_USER_ECR_SECRET"}, | ||
| "QUAY_USERNAME": {fromSecret: "PRODUCTION_QUAYIO_DOCKER_USERNAME"}, | ||
| "QUAY_PASSWORD": {fromSecret: "PRODUCTION_QUAYIO_DOCKER_PASSWORD"}, | ||
| }, | ||
| Volumes: dockerVolumeRefs(), | ||
| Commands: []string{ | ||
| "apk add --no-cache aws-cli", | ||
| "export VERSION=${DRONE_TAG##v}", | ||
| // authenticate with staging credentials | ||
| "aws ecr get-login-password --region=us-west-2 | docker login -u=\"AWS\" --password-stdin " + StagingRegistry, | ||
| // pull staging images | ||
| "echo \"---> Pulling images for $${VERSION}\"", | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport:$${VERSION}", StagingRegistry), | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport-ent:$${VERSION}", StagingRegistry), | ||
| fmt.Sprintf("docker pull %s/gravitational/teleport-ent:$${VERSION}-fips", StagingRegistry), | ||
| // retag images to production naming | ||
| "echo \"---> Tagging images for $${VERSION}\"", | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport:$${VERSION} %s/gravitational/teleport:$${VERSION}", StagingRegistry, ProductionRegistryQuay), | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport-ent:$${VERSION} %s/gravitational/teleport-ent:$${VERSION}", StagingRegistry, ProductionRegistryQuay), | ||
| fmt.Sprintf("docker tag %s/gravitational/teleport-ent:$${VERSION}-fips %s/gravitational/teleport-ent:$${VERSION}-fips", StagingRegistry, ProductionRegistryQuay), | ||
| // authenticate with production credentials | ||
| "docker logout " + StagingRegistry, | ||
| "docker login -u=\"$QUAY_USERNAME\" -p=\"$QUAY_PASSWORD\" " + ProductionRegistryQuay, | ||
| // push production images | ||
| "echo \"---> Pushing images for $${VERSION}\"", | ||
| fmt.Sprintf("docker push %s/gravitational/teleport:$${VERSION}", ProductionRegistryQuay), | ||
| fmt.Sprintf("docker push %s/gravitational/teleport-ent:$${VERSION}", ProductionRegistryQuay), | ||
| fmt.Sprintf("docker push %s/gravitational/teleport-ent:$${VERSION}-fips", ProductionRegistryQuay), | ||
| }, | ||
| }) | ||
|
|
||
| return dockerPipeline | ||
| } |
Submodule e
updated
from ffe8c9 to 7868ba
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.