This lab requires an AWS Cloud9 IDE. If you do not have an AWS Cloud9 IDE set up, complete the Prepartion section of the workshop.
In this section, you will create a Docker container for the application and a buildspec file.
Open the AWS Cloud9 console.
Choose open IDE for the Cloud9 instance set up previously. It may take a few moments for the IDE to open. AWS Cloud9 stops and restarts the instance so that you do not pay compute charges when no longer using the Cloud9 IDE.
Create a new directory called MyDemoRepo and enter it:
mkdir MyDemoRepo
cd MyDemoRepo
pwd # should be /home/ec2-user/environment/MyDemoRepo
cat > ~/environment/MyDemoRepo/spack.yaml <<EOF
spack:
specs:
- gromacs
- osu-micro-benchmarks
packages:
all:
target: [ x86_64_v3 ]
concretizer:
unify: true
config:
install_tree: /opt/software
view: /opt/view
EOF
cat > ~/environment/MyDemoRepo/Dockerfile << EOF
FROM spack/amazon-linux:v0.18.0 as build
# Add our spack.yaml file that defines our build and environment
ADD spack.yaml /opt/spack-environment/spack.yaml
# Set up spack env & binary cache, then build the software
RUN spack env activate -d /opt/spack-environment \
&& spack mirror add binary_mirror https://binaries.spack.io/releases/v0.18 \
&& spack buildcache keys --install --trust \
&& spack install --reuse --use-cache --fail-fast \
&& spack gc -y \
&& spack find -v
# Create a script to activate the spack environment on load
RUN spack env activate --sh -v -d /opt/spack-environment > /etc/profile.d/z10_spack_environment.sh
ENTRYPOINT [ "/bin/bash", "-l" ]
EOF
Before you move on to building an automated CICD pipeline, you will build and run the container and push it to an Elastic Container Registry (ECR) container repository.
You will be using the Elastic Container repository (ECR) to store and distribute your container images once they are built. Create the repository now.
aws ecr create-repository --repository-name sc22-container
You will use the repositoryUri later to reference this repositry. Fetch and display the URI with.
export IMAGE_URI=$(aws ecr describe-repositories --repository-name sc22-container --query "repositories[0].repositoryUri" --output text)
echo $IMAGE_URI
In the next steps, you will use automated CICD pipeline tools to build the container image and update ECR. In addition to the automation, the CICD pipeline provides a sandbox environment with the ability to limit access to AWS resources using AWS IAM while having elevated privileges.