Loading osm data to PostgreSQL during docker build

Almost the same as Import osm data in Docker postgresql BUT I want to load the osm data into the postgres via osm2pgsql during the docker build phase.

The reason for this are:

  1. I only want to load a fixed osm file inside my postgres, meaning this data will not change.
  2. I want to reuse this docker image as many times as possible.
  3. It is not possible to mount any volume with my current environment.

I know that this will make the docker image big but that is something I already took into consideration.

Source: StackOverflow