-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): support ssh build arg in DockerImageAsset (#26356)
Adds support for the docker build --ssh flag for specifying ssh agent socket or ssh keys for ecr DockerImageAsset ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
4bf0762
commit 7b3d381
Showing
22 changed files
with
296 additions
and
40 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
packages/@aws-cdk-testing/framework-integ/test/aws-ecr-assets/test/demo-image-ssh/Dockerfile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
FROM public.ecr.aws/lambda/python:3.6 | ||
RUN yum makecache fast | ||
RUN yum install -y openssh-clients | ||
RUN ssh-keygen -t rsa -b 2048 -f /root/.ssh/id_rsa -q -N "" | ||
RUN ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub | ||
RUN cat /root/.ssh/id_rsa.pub >> out.pub | ||
WORKDIR /app | ||
EXPOSE 8000 | ||
ADD . /app | ||
CMD python3 index.py |
35 changes: 35 additions & 0 deletions
35
packages/@aws-cdk-testing/framework-integ/test/aws-ecr-assets/test/demo-image-ssh/index.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
import os | ||
import sys | ||
import textwrap | ||
import http.server | ||
import socketserver | ||
|
||
PORT = 8000 | ||
|
||
class Handler(http.server.SimpleHTTPRequestHandler): | ||
def do_GET(self): | ||
with open('/root/.ssh/id_rsa.pub', 'r') as file: | ||
data = file.read() | ||
|
||
self.send_response(200) | ||
self.send_header('Content-Type', 'text/html') | ||
self.end_headers() | ||
self.wfile.write(textwrap.dedent(f'''\ | ||
<!doctype html> | ||
<html><head><title>It works</title></head> | ||
<body> | ||
<h1>Hello from the integ test container</h1> | ||
<p>This container got built and started as part of the integ test.</p> | ||
<p>Public key: {data}</p> | ||
<img src="https://media.giphy.com/media/nFjDu1LjEADh6/giphy.gif"> | ||
</body> | ||
''').encode('utf-8')) | ||
|
||
def main(): | ||
httpd = http.server.HTTPServer(("", PORT), Handler) | ||
print("serving at port", PORT) | ||
httpd.serve_forever() | ||
|
||
if __name__ == '__main__': | ||
main() |
7 changes: 7 additions & 0 deletions
7
...napshot/asset.6308cecadfac022764e8f3e3272baeab95b48a260cae3978b7ef93bd3ff2be17/Dockerfile
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM public.ecr.aws/lambda/python:3.6 | ||
RUN yum makecache fast | ||
RUN yum install -y openssh-clients | ||
RUN ssh-keygen -t rsa -b 2048 -f /root/.ssh/id_rsa -q -N "" | ||
RUN ssh-keygen -y -f /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub | ||
WORKDIR /app | ||
CMD python3 index.py |
35 changes: 35 additions & 0 deletions
35
....snapshot/asset.6308cecadfac022764e8f3e3272baeab95b48a260cae3978b7ef93bd3ff2be17/index.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/python | ||
import os | ||
import sys | ||
import textwrap | ||
import http.server | ||
import socketserver | ||
|
||
PORT = 8000 | ||
|
||
class Handler(http.server.SimpleHTTPRequestHandler): | ||
def do_GET(self): | ||
with open('/root/.ssh/id_rsa.pub', 'r') as file: | ||
data = file.read() | ||
|
||
self.send_response(200) | ||
self.send_header('Content-Type', 'text/html') | ||
self.end_headers() | ||
self.wfile.write(textwrap.dedent(f'''\ | ||
<!doctype html> | ||
<html><head><title>It works</title></head> | ||
<body> | ||
<h1>Hello from the integ test container</h1> | ||
<p>This container got built and started as part of the integ test.</p> | ||
<p>Public key: {data}</p> | ||
<img src="https://media.giphy.com/media/nFjDu1LjEADh6/giphy.gif"> | ||
</body> | ||
''').encode('utf-8')) | ||
|
||
def main(): | ||
httpd = http.server.HTTPServer(("", PORT), Handler) | ||
print("serving at port", PORT) | ||
httpd.serve_forever() | ||
|
||
if __name__ == '__main__': | ||
main() |
2 changes: 1 addition & 1 deletion
2
...-testing/framework-integ/test/aws-ecr-assets/test/integ.assets-docker.js.snapshot/cdk.out
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
{"version":"29.0.0"} | ||
{"version":"33.0.0"} |
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
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
2 changes: 1 addition & 1 deletion
2
...sting/framework-integ/test/aws-ecr-assets/test/integ.assets-docker.js.snapshot/integ.json
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"version": "29.0.0", | ||
"version": "33.0.0", | ||
"testCases": { | ||
"integ.assets-docker": { | ||
"stacks": [ | ||
|
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
Oops, something went wrong.