DEV Community


Posted on • Updated on


To achieve the tasks you've outlined, you'll need to follow these steps:

  1. Create a GitHub Repo with HTML Page:
  • Create a new GitHub repository.
  • Add an HTML file (e.g., index.html) to the repository.
  1. Create a Dockerfile:
  • In your GitHub repository, create a Dockerfile that defines how to build your Docker image. Here's a simple example:
   # Use an official Nginx runtime as a parent image
   FROM nginx:alpine

   # Copy your HTML file into the Nginx web root directory
   COPY index.html /usr/share/nginx/html

   # Expose port 80 to listen for incoming HTTP requests
   EXPOSE 80

   # Start Nginx
   CMD ["nginx", "-g", "daemon off;"]
Enter fullscreen mode Exit fullscreen mode
  1. Write a Shell Script:

Create a shell script (e.g., with the following content:


   # Clone the GitHub repo
   git clone

   # Navigate to the repo directory
   cd your-repo

   # Build the Docker image
   docker build -t your-image-name .

   # Push the Docker image to Docker Hub
   docker push your-dockerhub-username/your-image-name

   # Run the Docker container
   docker run -d -p 80:80 your-dockerhub-username/your-image-name
Enter fullscreen mode Exit fullscreen mode

Make sure to replace yourusername, your-repo, your-image-name, and your-dockerhub-username with your actual GitHub and Docker Hub information.

  1. Execute the Shell Script via Cron:

To run the shell script every 10 minutes, you can set up a cron job. Edit your crontab file by running:

   crontab -e
Enter fullscreen mode Exit fullscreen mode

Then add the following line to schedule the script execution:

   */10 * * * * /path/to/
Enter fullscreen mode Exit fullscreen mode

Replace /path/to/ with the actual path to your shell script.

  1. Make Changes to index.html:

Edit your index.html file in your GitHub repository to make the desired changes.

  1. Check the Browser After 15 Minutes:

After making changes to index.html, commit and push the changes to your GitHub repository. Wait for 15 minutes, and the updated content should be reflected when you access the website in your browser.

  1. Push the Build Shell Script to the Same Repo:

Add the shell script to your GitHub repository:

   git add
   git commit -m "Add script"
   git push
Enter fullscreen mode Exit fullscreen mode

Now you have a setup that automatically builds and deploys your HTML page using Docker, updates it every 10 minutes via a cron job, and reflects changes in the browser after 15 minutes when you make updates to index.html.

Top comments (0)