how can I automate this process? I have an script to push dockerimage to AWS through ecr.
You are on the right track. Yes, this should be an automated process from Git push or when someone merge a Pull Request.
An important aspect of this is that this "automated process" should be on a dedicated system - such that it is repeatable in a consistent ...
If you simply need to build a docker image, I recommend using Kaniko. It allows you to build a docker image without having to expose the docker.sock or running your pods in privileged mode, which introduces potential security vulnerabilities. Per the Kaniko documentation, your spec file would look similar to:
As per compute/docs/troubleshooting/known-issues:
On Debian and Ubuntu based systems, including your local workstations,
you might encounter an error similar to the following example:
[...] The following signatures were invalid: XXXX [...]
To resolve this error, get the latest valid apt-key.gpg key file from https://packages.cloud.google.com by running the ...