Skip to content

Commit

Permalink
updated Java ECR files
Browse files Browse the repository at this point in the history
  • Loading branch information
scmacdon committed Jun 18, 2024
1 parent a64533b commit 5e2c89a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions getting_started_scenarios/ecr_scenario/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Note: These steps are not the complete program, but summarizes the 5-6 high-leve

The basic scenario requires an IAM role that has Amazon ECR permissions. To create an IAM role, see [Creating IAM roles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create.html).

In addtion, this scenario requires a local Docker image created using Bash. To create a local "Hello World" Docker image using Bash:
This scenario requires a local Docker image created using Bash. To create a local Docker image named "echo-text" using Bash, perform these steps:

1. **Install Docker**: First, you'll need to install Docker and Docker Desktop on your system. You can download the appropriate Docker version for your operating system from the official Docker website (https://www.docker.com/get-started).

Expand Down Expand Up @@ -62,29 +62,29 @@ In addtion, this scenario requires a local Docker image created using Bash. To c

```bash
#!/bin/sh
echo "Hello, World!"
echo "Hello There!"
```

This is a simple Bash script that prints "Hello, World!" to the console.
This is a simple Bash script that prints "Hello There!" to the console.

5. **Build the Docker image**: In the same directory as the Dockerfile and `hello.sh` script, run the following command to build the Docker image:

```bash
docker build -t hello-world .
docker build -t echo-text .
```

This command builds a Docker image with the tag "hello-world" using the instructions in the Dockerfile.
This command builds a Docker image with the tag "echo-text" using the instructions in the Dockerfile.

6. **Run the Docker container**: Once the image is built, you can run a container based on the "hello-world" image by executing the following command:
6. **Run the Docker container**: Once the image is built, you can run a container based on the "echo-text" image by executing the following command:

```bash
docker run hello-world
docker run echo-text
```


## Implementations

This example will be implemented in the following languages:
This scenario example will be implemented in the following languages:

- Java
- Python
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ public void pushDockerImage(String repoName, String imageName) {
Repository repoData = descrRepoResponse.repositories().stream().filter(r -> r.repositoryName().equals(repoName)).findFirst().orElse(null);
getDockerClient().tagImageCmd(imageName+":latest", repoData.repositoryUri() + ":latest", imageName).exec();
try {
getDockerClient().pushImageCmd(repoData.repositoryUri()).withTag("hello-world").withAuthConfig(authConfig).start().awaitCompletion();
getDockerClient().pushImageCmd(repoData.repositoryUri()).withTag("echo-text").withAuthConfig(authConfig).start().awaitCompletion();
System.out.println("The "+imageName+" was pushed to ECR");
} catch (InterruptedException e) {
throw new RuntimeException(e);
Expand All @@ -540,18 +540,18 @@ public boolean listLocalImages() {
String[] repoTags = image.getRepoTags();
if (repoTags != null) {
for (String tag : repoTags) {
if (tag.startsWith("hello-world")) {
if (tag.startsWith("echo-text")) {
System.out.println(tag);
helloWorldFound = true;
}
}
}
}
if (helloWorldFound) {
System.out.println("The local image named hello-world exists.");
System.out.println("The local image named echo-text exists.");
return true;
} else {
System.out.println("The local image named hello-world does not exist.");
System.out.println("The local image named echo-text does not exist.");
return false;
}
} catch (DockerClientException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create.html
*
* This Java code example also requires a local docker image named hello-world. For more information. see:
* This Java scenario example requires a local docker image named echo-text. For more information. see:
*
* /getting_started_scenarios/ecr_scenario/README
*
Expand Down Expand Up @@ -71,23 +71,23 @@ The Amazon Elastic Container Registry (ECR) is a fully-managed Docker container
System.out.println("""
1. Create an ECR repository.
The first task is to ensure we have a local Docker image named hello-world.
The first task is to ensure we have a local Docker image named echo-text.
If this image exists, then an Amazon ECR repository is created.
An ECR repository is a private Docker container repository provided
by Amazon Web Services (AWS). It is a managed service that makes it easy
to store, manage, and deploy Docker container images.\s
""" );

// Ensure that a local docker image named hello-world exists.
// Ensure that a local docker image named echo-text exists.
boolean doesExist = ecrActions.listLocalImages();
String repoName;
if (!doesExist){
System.out.println("The local image named hello-world does not exist");
System.out.println("The local image named echo-text does not exist");
return;
} else {
localImageName = "hello-world";
repoName = "hello-world";
localImageName = "echo-text";
repoName = "echo-text";
}

String repoArn = String.valueOf(ecrActions.createECRRepository(repoName));
Expand Down Expand Up @@ -228,7 +228,7 @@ or use the force option (used in this scenario) to delete the repository and hav
}

System.out.println(DASHES);
System.out.println("This concludes the Amazon ECR SDK Getting Started scenario");
System.out.println("This concludes the Amazon ECR SDK scenario");
System.out.println(DASHES);
}

Expand Down

0 comments on commit 5e2c89a

Please sign in to comment.