I would like to build docker image and push to ECR using concourse pipeline

How i can create a pipeline that builds the docker image from the dockerfile and pushs it to ECR via concourse.

You can use the OCI build task to build the image then push the image.tar file that it produces to ECR with the registry-image resource which is included in Concourse.

We anyhow need to have Docker daemon available for a task on Concourse to run the tests (with TestContainers), so we loosely followed this approach and as a consequence we are able to build and push docker images within the task.

For us, building and pushing Docker images was a part of our build tool (also available locally on dev machines) with a Gradle plugin.

Although very specific to JVM (Gradle and Maven), there are ways (similar to “OCI build task”, I presume) to build Docker images without the need for a running Docker daemon. E.g., Google JIB.