Best way for Docker post run provisioning

I am quite new to Docker, and I am trying to find which is the best way for Docker provisioning after my container is up.
We use the docker-compose file to make our container up and our compose file looks like this.

version: "3"

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:   
      DB_HOST: $DB_HOST
      DB_PORT: $DB_PORT
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      DB_DRIVER: $DB_DRIVER
      PHP_FPM_USER: wodby
      PHP_FPM_GROUP: wodby
      COLUMNS: 80 # Set 80 columns for docker exec -it.
    volumes:
      - ./Insider:/var/www/html

  nginx:
    image: wodby/nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
      - php
    environment:
      NGINX_STATIC_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
      NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
    ports:
      - '8000:80'
    volumes:
      - ./Insider:/var/www/html

Now we need to perform some setup tasks once PHP container is up. Now I need some idea on what is the best way to perform provisioning in this container. We have 2 ideas and they are as follows.

  1. Write a shell script and put it as one of the tasks in our build process.
  2. Use ansible and connect from a different server to do the provision.

but the ideal process would be, if we can somehow include a shell script in PHP container from our docker-compose.yml file and when we would run docker-compose up -d it should run as part of that container up process and make everything ready, so we do not need to go through 2nd command/process and so on.

Source: StackOverflow