Skip to content

Commit cf53ec0

Browse files
authored
Merge pull request #4107 from awsdocs/docker-push
Add docker image production workflow to repo 🔥
2 parents 5066c52 + d1b827e commit cf53ec0

File tree

32 files changed

+9262
-4
lines changed

32 files changed

+9262
-4
lines changed

.doc_gen/images/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Metadata generation for ECR repositories
2+
The files in this directory are used to generate text that is manually copied into our
3+
[ECR CDK stack file](resources/cdk/ecr_repositories/ecr_repositories-stack.ts) which is
4+
used as the source config file for our ECR repositories.
5+
6+
This is not example code and is used internally by the AWS team responsible for maintaining
7+
this repository.

.doc_gen/images/render-blurbs.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import jinja2
2+
import yaml
3+
import os
4+
5+
env = jinja2.Environment(
6+
loader=jinja2.FileSystemLoader(os.path.dirname(__file__))
7+
)
8+
9+
with open('../metadata/sdks.yaml', 'r') as file:
10+
metadata = yaml.safe_load(file)
11+
for language in metadata.keys():
12+
metadata[language]
13+
shortname = metadata[language]['property']
14+
template = env.get_template("template.txt")
15+
print(template.render(language=language, shortname=shortname))
16+
17+
18+

.doc_gen/images/template.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
new ecr.CfnPublicRepository(this, "{{shortname}}", {
2+
repositoryName: "{{shortname}}",
3+
repositoryCatalogData: {
4+
UsageText: "This image provides a pre-built for SDK for {{language}} environment and is recommended for local testing of SDK for {{language}} example code. It is not intended for production usage. For detailed and up-to-date steps on running this image, please see https://github.com/awsdocs/aws-doc-sdk-examples/blob/main/{{shortname}}/README.md#docker-image.",
5+
OperatingSystems: ["Linux"],
6+
Architectures: ["x86", "ARM"],
7+
RepositoryDescription: "This image provides a pre-built for SDK for {{language}} environment and is recommended for local testing of SDK for {{language}} example code."
8+
},
9+
});

.github/workflows/docker-push.yml

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
name: Docker Image CI
2+
3+
permissions:
4+
packages: write
5+
contents: read
6+
id-token: write
7+
8+
on:
9+
pull_request_target:
10+
types:
11+
- closed
12+
branches:
13+
- 'main'
14+
15+
jobs:
16+
push_to_registry:
17+
if: github.event.pull_request.merged == true
18+
env:
19+
REGISTRY: public.ecr.aws
20+
REGISTRY_ALIAS: b4v4v1s0
21+
IMAGE_TAG: latest
22+
REGION: us-east-1
23+
name: Push Docker image to Docker Hub
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Check out the repo
27+
uses: actions/checkout@v3
28+
29+
##################################################
30+
################## ECR PUBLIC ####################
31+
##################################################
32+
33+
- name: Configure AWS credentials
34+
uses: aws-actions/configure-aws-credentials@master # More information on this action can be found below in the 'AWS Credentials' section
35+
with:
36+
role-to-assume: arn:aws:iam::808326389482:role/automation
37+
aws-region: us-east-1
38+
39+
- name: Login to Amazon ECR Public
40+
id: login-ecr-public
41+
uses: aws-actions/amazon-ecr-login@v1
42+
with:
43+
registry-type: public
44+
45+
###############################
46+
###### Docker Image: #######
47+
###### RUBY #######
48+
###############################
49+
- name: Build, tag, and push docker image to Amazon ECR Public - Ruby
50+
if: contains(github.event.pull_request.labels.*.name, 'lang/ruby')
51+
env:
52+
REPOSITORY: ruby
53+
run: |
54+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
55+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
56+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
57+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
58+
59+
#################################
60+
###### Docker Image: #######
61+
###### PYTHON #######
62+
#################################
63+
- name: Build, tag, and push docker image to Amazon ECR Public - Python
64+
if: contains(github.event.pull_request.labels.*.name, 'lang/python')
65+
env:
66+
REPOSITORY: python
67+
run: |
68+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
69+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
70+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
71+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
72+
73+
#################################
74+
####### Docker Image: ########
75+
####### JAVASCRIPT v3 ########
76+
#################################
77+
- name: Build, tag, and push docker image to Amazon ECR Public - JavaScript
78+
if: contains(github.event.pull_request.labels.*.name, 'lang/javascript-v3')
79+
env:
80+
REPOSITORY: javascriptv3
81+
run: |
82+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
83+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
84+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
85+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
86+
87+
#################################
88+
####### Docker Image: ########
89+
####### RUST ########
90+
#################################
91+
- name: Build, tag, and push docker image to Amazon ECR Public - Rust
92+
if: contains(github.event.pull_request.labels.*.name, 'lang/rust')
93+
env:
94+
REPOSITORY: rust_dev_preview
95+
run: |
96+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
97+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
98+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
99+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
100+
101+
#################################
102+
####### Docker Image: ########
103+
####### GO v2 ########
104+
#################################
105+
- name: Build, tag, and push docker image to Amazon ECR Public - GoLang
106+
if: contains(github.event.pull_request.labels.*.name, 'lang/gov-2')
107+
env:
108+
REPOSITORY: gov2
109+
run: |
110+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
111+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
112+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
113+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
114+
115+
#################################
116+
####### Docker Image: ########
117+
####### C++ ########
118+
#################################
119+
- name: Build, tag, and push docker image to Amazon ECR Public - C++
120+
if: contains(github.event.pull_request.labels.*.name, 'lang/cpp')
121+
env:
122+
REPOSITORY: cpp
123+
run: |
124+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
125+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
126+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
127+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
128+
129+
#################################
130+
####### Docker Image: ########
131+
####### .NET v3 ########
132+
#################################
133+
- name: Build, tag, and push docker image to Amazon ECR Public - .NET v3
134+
if: contains(github.event.pull_request.labels.*.name, 'lang/dotnet-v3')
135+
env:
136+
REPOSITORY: dotnetv3
137+
run: |
138+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
139+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
140+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
141+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
142+
143+
#################################
144+
####### Docker Image: ########
145+
####### JAVA v2 ########
146+
#################################
147+
- name: Build, tag, and push docker image to Amazon ECR Public - JavaV2
148+
if: contains(github.event.pull_request.labels.*.name, 'lang/java-v2')
149+
env:
150+
REPOSITORY: javav2
151+
run: |
152+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
153+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
154+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
155+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
156+
157+
#################################
158+
####### Docker Image: ########
159+
####### KOTLIN ########
160+
#################################
161+
- name: Build, tag, and push docker image to Amazon ECR Public - Kotlin
162+
if: contains(github.event.pull_request.labels.*.name, 'lang/kotlin')
163+
env:
164+
REPOSITORY: kotlin
165+
run: |
166+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
167+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
168+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
169+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
170+
171+
#################################
172+
####### Docker Image: ########
173+
####### PHP ########
174+
#################################
175+
- name: Build, tag, and push docker image to Amazon ECR Public - PHP
176+
if: contains(github.event.pull_request.labels.*.name, 'lang/php')
177+
env:
178+
REPOSITORY: php
179+
run: |
180+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
181+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
182+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
183+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
184+
185+
#################################
186+
####### Docker Image: ########
187+
####### SWIFT ########
188+
#################################
189+
- name: Build, tag, and push docker image to Amazon ECR Public - Swift
190+
if: contains(github.event.pull_request.labels.*.name, 'lang/swift')
191+
env:
192+
REPOSITORY: swift
193+
run: |
194+
aws ecr-public get-login-password --region $REGION | docker login --username AWS --password-stdin $REGISTRY/$REGISTRY_ALIAS
195+
docker build -t $REPOSITORY -f ./$REPOSITORY/Dockerfile .
196+
docker tag $REPOSITORY:$IMAGE_TAG $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
197+
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG

cpp/Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# syntax=docker/dockerfile:1
2+
# Status: Beta
3+
# GA updates: https://github.com/awsdocs/aws-doc-sdk-examples/issues/4133
4+
FROM gcc:4.9
5+
RUN mkdir /src
6+
COPY . /src/
7+
WORKDIR /src
8+
CMD ["bash"]

cpp/README.rst

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Before using the Code Examples, first complete the installation and setup steps
2323
Developer Guide.
2424

2525
The Getting Started section covers how to obtain and build the SDK, and how to build your own
26-
code utilizing the SDK with a sample Hello World-style application. A similar procedure is
26+
code utilizing the SDK with a sample "Hello World"-style application. A similar procedure is
2727
applicable to utilizing the code examples in this repository.
2828

2929
Building and running the code examples
@@ -32,6 +32,21 @@ Building and running the code examples
3232
Additional information geared specifically to understanding the example applications is at
3333
`AWS SDK for C++ Code Examples <https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/programming-services.html>`_.
3434

35+
36+
Docker image (Beta)
37+
===================
38+
39+
In the near future, this example code will be available in a container image
40+
hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html). This image will be pre-loaded
41+
with all C++ examples with dependencies pre-resolved, allowing you to explore
42+
these examples in an isolated environment.
43+
44+
As of January 2023, the [SDK for C++ image](https://gallery.ecr.aws/aws-docs-sdk-examples/cpp) is available on ECR Public but is still
45+
undergoing active development. Refer to
46+
[this GitHub issue](https://github.com/awsdocs/aws-doc-sdk-examples/issues/4133)
47+
for more information.
48+
49+
3550
Additional information
3651
=============
3752

@@ -46,16 +61,15 @@ Additional information
4661
- To propose a new code example for the AWS documentation team to consider producing, create a
4762
new request. The team is looking to produce code examples that cover broader scenarios and use
4863
cases, versus simple code snippets that cover only individual API calls. For instructions, see
49-
the Proposing new code examples section in the
64+
the Proposing new code examples section in the
5065
`Readme on GitHub <https://github.com/awsdocs/aws-doc-sdk-examples/blob/master/README.rst>`_.
5166

5267
Copyright and License
5368
=============
5469

5570
All content in this repository, unless otherwise stated, is
56-
Copyright © Amazon Web Services, Inc. or its affiliates. All rights reserved.
71+
Copyright © Amazon Web Services, Inc. or its affiliates. All rights reserved.
5772

5873
Except where otherwise noted, all examples in this collection are licensed under the `Apache
5974
license, version 2.0 <https://www.apache.org/licenses/LICENSE-2.0>`_ (the "License"). The full
6075
license text is provided in the `LICENSE` file accompanying this repository.
61-

dotnetv3/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# syntax=docker/dockerfile:1
2+
# Status: Beta
3+
# GA updates: https://github.com/awsdocs/aws-doc-sdk-examples/issues/4126
4+
FROM mcr.microsoft.com/dotnet/sdk:6.0
5+
RUN mkdir /src
6+
COPY . /src/
7+
WORKDIR /src/dotnetv3/SES
8+
RUN dotnet build
9+
CMD ["bash"]

dotnetv3/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ If you want more information, run:
129129
dotnet test -l "console;verbosity=detailed"
130130
```
131131

132+
## Docker image (Beta)
133+
In the near future, this example code will be available in a container image
134+
hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html). This image will be pre-loaded
135+
with all .NET examples with dependencies pre-resolved, allowing you to explore
136+
these examples in an isolated environment.
137+
138+
⚠️ As of January 2023, the [SDK for .NET v3 image](https://gallery.ecr.aws/aws-docs-sdk-examples/dotnetv3) is available on ECR Public but is still
139+
undergoing active development. Refer to
140+
[this GitHub issue](https://github.com/awsdocs/aws-doc-sdk-examples/issues/4126)
141+
for more information.
142+
132143
## Additional resources
133144

134145
- As an AWS best practice, grant all code least privilege, or only the permissions required to perform a task. For more information, see [Grant Least Privilege](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#grant-least-privilege) in the *AWS Identity and Access Management User Guide*.

gov2/Dockerfile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# syntax=docker/dockerfile:1
2+
# Status: Beta
3+
# GA updates: https://github.com/awsdocs/aws-doc-sdk-examples/issues/4129
4+
FROM golang:1.19.2
5+
RUN mkdir /src
6+
COPY . /src/
7+
WORKDIR /src/gov2/dynamodb
8+
RUN go build ./...
9+
CMD ["bash"]

gov2/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ command prompt by including the `integration` tag.
7979
go test -tags=integration ./...
8080
```
8181

82+
## Docker image (Beta)
83+
In the near future, this example code will be available in a container image
84+
hosted on [Amazon Elastic Container Registry (ECR)](https://docs.aws.amazon.com/AmazonECR/latest/userguide/what-is-ecr.html). This image will be pre-loaded
85+
with all Golang examples with dependencies pre-resolved, allowing you to explore
86+
these examples in an isolated environment.
87+
88+
⚠️ As of January 2023, the [SDK for Go v2 image](https://gallery.ecr.aws/aws-docs-sdk-examples/dotnetv3) is available on ECR Public but is still
89+
undergoing active development. Refer to
90+
[this GitHub issue](https://github.com/awsdocs/aws-doc-sdk-examples/issues/4129)
91+
for more information.
92+
8293
## Additional resources
8394

8495
* [AWS SDK for Go (v2) Developer Guide](https://aws.github.io/aws-sdk-go-v2/docs/)

0 commit comments

Comments
 (0)