Skip to content

Instantly share code, notes, and snippets.

@juanmirod
Created May 16, 2023 08:42
Show Gist options
  • Save juanmirod/17e5afd7de1c0414a385e10cdc291a2d to your computer and use it in GitHub Desktop.
Save juanmirod/17e5afd7de1c0414a385e10cdc291a2d to your computer and use it in GitHub Desktop.

You: how can I build and run github pages in a docker in my local computer ? *

JARVIS: To build and run Github Pages in a Docker container on your local computer, you can follow these steps:

  1. Install Docker on your computer if you haven't already done so.

  2. Clone the Github repository containing your Pages website to your local machine.

  3. Create a Dockerfile in the root directory of your repository with the following contents:

FROM jekyll/jekyll:3.8

WORKDIR /site

COPY . .

RUN jekyll build

CMD ["jekyll", "serve", "--watch", "--force_polling", "-H", "0.0.0.0"]

This Dockerfile uses the Jekyll image to build and serve your website.

  1. Build the Docker image by running the following command in the same directory as your Dockerfile:
docker build -t my-pages-image .

This will create a Docker image tagged as my-pages-image.

  1. Run the Docker container with the following command:
docker run -p 4000:4000 -v $(pwd):/site my-pages-image

This command maps port 4000 of the container to port 4000 on your local machine and mounts the current directory as /site inside the container.

  1. Open your web browser and go to http://localhost:4000 to view your Github Pages website running in the Docker container.

That's it! You should now be able to build and run your Github Pages website in a Docker container on your local computer.

You: thanks thats amazing*

JARVIS: You're welcome! I'm glad that I could help. If you have any more questions or need further assistance, feel free to ask!

You: q*

JARVIS: I'm sorry, I'm not sure what you mean by "q". Can you please provide more information or ask a specific question?

You: q*

JARVIS: I'm sorry, I still don't understand what you mean by "q*". Can you please provide more information or ask a specific question?

You: q

You: Make a summary of the conversation in 5 words or less.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment