Write a new entrypoint script.
#!/bin/bash
/bin/api "$@"
# perhaps
source /script.sh
# or exec
exec /script.sh
Copy this into your image on build.
COPY --chmod=755 entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]
This will result in the arguments you are passing in your compose file to be passed to /bin/api, and after that your script is executed.
I am not sure if that would be actually useful. The API command looks like it's initiating a long-running process, so your script might never really run.
You could also dome something like this in your entrypoint.
#!/bin/bash
run_script(){
sleep 5
source /script.sh
}
run_script &
exec /bin/api "$@"
It would hide errors from that script though, so its not really solid.
This would run the function in the background, which would sleep 5 seconds to give the API time to start, and then run the script while the API is running.
It's hard to say, without knowing what your script is doing, what would be a good solution. The second suggestion feels definitely a bit hacky.
-config
looks like an argument to some other command. What's in the image's Dockerfile; does it have anENTRYPOINT
declaration, to which thiscommand:
is arguments?