Hello,
I am trying to get up and running with Spring Boot, Maven, and AWS. I am following this tutorial.
I had to install a different version of maven, as when I ran sudo tar xf /tmp/apache-maven-*.tar.gz -C /opt
under Install Apache Maven the console said it wasn't able to unzip apache-maven-3.8.1-bin.tar.gz
. I had to download a different version, apache-maven-3.9.6-bin.tar.gz
and I was able to unzip this.
I also had to change M2_HOME
to M3_HOME
under Set up Apache Maven, and I had to unset M2_HOME
. Then I was able to proceed.
In Cloud 9, the return of mvn --version
is
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00)
Maven home: /usr/share/apache-maven
Java version: 17.0.9, vendor: Amazon.com Inc.
Java home: /usr/lib/jvm/java-17-amazon-corretto.x86_64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "6.1.66-91.160.amzn2023.x86_64", arch: "amd64", family: "unix"
I am at the part Build and tag the Petclinic docker image. When I execute the command docker build -t petclinic .
the console returns
=> [internal] load build definition from Dockerfile
...
=> ERROR [2/4] ADD target/spring-petclinic-2.3.0.jar app.jar 0.0s
------
> [2/4] ADD target/spring-petclinic-2.3.0.jar app.jar:
------
Dockerfile:3
--------------------
1 | FROM public.ecr.aws/bitnami/java:latest
2 | VOLUME /tmp
3 | >>> ADD target/spring-petclinic-2.3.0.jar app.jar
4 | EXPOSE 80
5 | RUN apt-get update
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 3f20ae07-a774-435d-86a5-f05e04520cc5::ljcblcc6ijbrhcn5q5fi0vwyr: "/target/spring-petclinic-2.3.0.jar": not found
I am trying to fix the error caused by ADD target/spring-petclinic-2.3.0.jar app.jar
.
My Dockerfile is
FROM public.ecr.aws/bitnami/java:latest
VOLUME /tmp
ADD target/spring-petclinic-2.3.0.jar app.jar
EXPOSE 80
RUN apt-get update
RUN apt-get -y install awscli
ENTRYPOINT env spring.datasource.password=$(aws ssm get-parameter --name /database/password --with-decrypt --region $AWS_REGION | grep Value | cut -d '"' -f4) java -Djava.security.egd=file:/dev/./urandom -jar /app.jar
I found this post which talks about commands relative to your Dockerfile
. I tried to update the command in my Dockerfile to
ADD /home/ec2-user/environment/aws-apprunner-terraform/petclinic/target/spring-petclinic-2.3.0.jar app.jar
but this returned a similar error to the one above.
The return of pwd
is
/home/ec2-user/environment/aws-apprunner-terraform/petclinic
and then the return of ls
is
Dockerfile docker-compose.yml pom.xml readme.md src
.
I noticed that target
directory is not there. Should it?
Thank you for the help in getting started with Spring!