First, you need to connect Jenkins with ECR using the Jenkins cloud configuration option in manage Jenkins.
You can select a far gate or EC2.
You can use your S3 artifacts in your docker image so that you can build your application while you run your Jenkins pipeline