How to execute shell script before docker build

I`d like to know is there good way to move folder/file, which is outside the building context, to
Inside the build context when docker-compose build.
Is that possible to solve by using or by using Docker-compose?

When I build this Dockerfile,

# set assets to inside docker container
COPY ../../frontend/src/assets /var/www/assets

And I did docker-compose build
However I got error about this

Step 19/21 : COPY ../../frontend/src/assets /var/www/assets
ERROR: Service 'test' failed to build: COPY failed: Forbidden path outside the build context: ../../frontend/src/assets ()

If I execute “ cp -rf ../../frontend/src/assets ./“ before build and change path of folder in Dockerfile, this is no problem,
But if I could, I want to make this less operation.

Source: StackOverflow