Pack the Old, Deploy as Gold!
This post will guide you to pack your old Java EE application as a container and deploy it to AWS AppRunner.
- Download a copy of JBoss 4.2.3
- Create a Simple Java EE Application (or use your existing one!)
- Install Docker
- Create a Dockerfile
- Build and Tag the Docker Image
- Create an Amazon ECR private repository
- Tag and Push Image to ECR
- Create an AWS App Runner Service Using ECR Image URI
About | |
---|---|
✅ AWS Level | 200 - Intermediate |
⏱ Time to complete | 30 mins - 45 mins |
💰 Cost to complete | USD 1.00 |
🧩 Prerequisites | - An AWS Account (if you don't yet have one, create one and set up your environment) - An IAM user that has the access to create AWS resources. - Basic understanding of Java |
📢 Feedback | Any feedback, issues, or just a 👍 / 👎 ? |
⏰ Last Updated | 2022-10-19 |
1
2
3
mkdir javaee-docker
cd javaee-docker
unzip <downloaded_jboss.zip>
1
2
3
4
myapp
--WEB-INF
----web.xml
index.html
1
2
3
mkdir myapp
cd myapp
mkdir WEB-INF
myapp
directory with this simple content:1
2
3
4
5
<html>
<body>
<p>Hello!</p>
</body>
</html>
myapp/WEB-INF
:1
2
3
4
5
6
7
8
<web-app>
<description>Simple Java App!</description>
</web-app>
javaee.DockerFile
in your project directory with the following code:1
2
3
4
5
6
7
8
9
FROM amazoncorretto:8
EXPOSE 8080
COPY "jboss-4.2.3.GA" "/opt/jboss"
COPY "myapp" "/opt/jboss/server/default/deploy/myapp.war"
RUN find /opt/jboss | grep myapp
ENTRYPOINT ["/opt/jboss/bin/run.sh", "-b", "0.0.0.0"]
1
FROM amazoncorretto:8
1
EXPOSE 8080
1
COPY "JBoss-4.2.3.GA" "/opt/JBoss"
1
COPY "myapp" "/opt/JBoss/server/default/deploy/myapp.war"
1
RUN find /opt/JBoss | grep myapp
the port to 0.0.0.0:
1
ENTRYPOINT ["/opt/JBoss/bin/run.sh", "-b", "0.0.0.0"]
jboss:latest
:1
docker build --platform=linux/amd64 --no-cache --progress=plain -f javaee.DockerFile . -t javaee-app1:latest
javaee-app1
as the name of this repository and use default config for other parameters.1
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin 649770145326.dkr.ecr.us-east-1.amazonaws.com
1
docker tag javaee-app1:latest 649770145326.dkr.ecr.us-east-1.amazonaws.com/javaee-app1:latest
1
docker push 649770145326.dkr.ecr.us-east-1.amazonaws.com/javaee-app1:latest
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.