How do I reuse the same image across multiple services?

I have a docker compose file where two services use the same image (different roles for the same binary). How can I tell okteto to build and push the image only once?

The best way is to refer your docker compose file from an okteto manifest like this:

# okteto.yaml
deploy:
  compose: docker-compose.yml

Then, add a build section to your okteto manifest like this:

# okteto.yaml
build:
   app:
      context: .
deploy:
  compose: docker-compose.yml

and finally, refer to this image from your docker compose file like this:

# docker-compose.yaml
services:
  api:
    image: ${OKTETO_BUILD_APP_IMAGE}
    ports:
      - 8080:8080
    command: python app.py
  worker:
    image: ${OKTETO_BUILD_APP_IMAGE}
    command: python worker.py