Do you want to organize nginx and lua environments in dockerfile?

  docker, question

I just learned the next dockerfile, and want to make a mirror image, including nginx and lua environments. I don’t know how to write the dockerfile. I feel there are two ways:
First, install nginx and lua based on ubuntu image
FROM ubuntu
RUN apt-get install nginx
RUN apt-get install lua
Second, install lua based on nginx image
FROM nginx
RUN apt-get install lua

Please tell me what is the correct posture, please give specific writing examples, thank you!

Option 1 should be possible
In the second scenario, it depends on which mirror nginx itself is based on.
I am also looking at this information recently:)