This is a quick and easy way to write an HTML page directly in the same Dockerfile where you define the Nginx server.

Use case:
I needed a very basic placeholder page for a project before it was actually put online.
Since I use Coolify, which allows you to use a Dockerfile as an application's source, I could easily achieve the goal by simply editing the file directly within the dashboard and hitting "Deploy".

Below is the complete Dockerfile setup:

FROM nginx:alpine

# Create the HTML file
RUN echo '</span>\
\
\
My new project\
\
\
Lorem ipsum\
\
' > /usr/share/nginx/html/index.html

# Expose port 80
EXPOSE 80

# Run nginx in foreground
CMD ["nginx", "-g", "daemon off;"]



    Enter fullscreen mode
    


    Exit fullscreen mode