How do I deploy spring boot application to ECS?

Hi there, I am new to CI/CD and am struggling with something that I expect is a pretty common use-case, so hoping someone here can help out.

I have a spring-boot web application that I have successfully deployed on Amazon ECS. However, at the moment I am deploying it manually. I would like to set up a CI/CD process so it updates the ECS task definition and service on any commit to the main branch.

I’ve already followed this guide successfully for deploying a toy project to ECS, but I can’t figure out where to go next for adapting it to my own project.

Looking through the AWS/Deploy-ECS.gitlab-ci.yml template, I gather I need to specify my own build_artifact job. I’ve specified this as the following:

  - template: AWS/Deploy-ECS.gitlab-ci.yml
  image: maven:3-jdk-11
  stage: build
    - "mvn clean package -DskipTests"
      - target

This runs successfully, but later on in the build job I consistently get this error:

error: failed to solve: lstat /var/lib/docker/tmp/buildkit-mount852391355/target: no such file or directory

Is my build_artifact job just supposed to build the jar, or is it also supposed to build the docker image? If it is just supposed to build the jar, how do I ensure the jobs defined in the AWS/Deploy-ECS.gitlab-ci.yml can find the jar? If it is supposed to build the docker image, how do I ensure the later jobs can find it?

Kind regards,