From 23348603a9d142051bda5c9f4cc5c705fd645f52 Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Wed, 15 May 2024 09:36:32 -0700 Subject: [PATCH] aider: Create Dockerfile and scripts to build and run the Jekyll site locally using Docker. # Aider chat conversation: USER: i want to render my github pages jekyll site locally. in the scripts/ dir, make me a dockerfile and scripts to build and run it. ASSISTANT: To render your GitHub Pages Jekyll site locally using Docker, we need to create a Dockerfile and two scripts: one to build the Docker image and another to run the container. Here are the necessary files: 1. `scripts/Dockerfile` 2. `scripts/build.sh` 3. `scripts/run.sh` Let's create these files: scripts/Dockerfile ```python <<<<<<< SEARCH ======= # Use the official Jekyll image from Docker Hub FROM jekyll/jekyll:latest # Set the working directory WORKDIR /srv/jekyll # Copy the current directory contents into the container at /srv/jekyll COPY . /srv/jekyll # Install any needed packages specified in Gemfile RUN bundle install # Expose port 4000 to the host EXPOSE 4000 # Run Jekyll server CMD ["jekyll", "serve", "--host", "0.0.0.0"] >>>>>>> REPLACE ``` scripts/build.sh ```python <<<<<<< SEARCH ======= #!/bin/bash # Build the Docker image docker build -t my-jekyll-site -f scripts/Dockerfile . >>>>>>> REPLACE ``` scripts/run.sh ```python <<<<<<< SEARCH ======= #!/bin/bash # Run the Docker container docker run --rm -v "$PWD:/srv/jekyll" -p 4000:4000 my-jekyll-site >>>>>>> REPLACE ``` These scripts will allow you to build and run your Jekyll site locally using Docker. To use them, navigate to your project directory and run: ```sh bash scripts/build.sh bash scripts/run.sh ``` This will build the Docker image and start a container that serves your Jekyll site on `http://localhost:4000`. --- scripts/Dockerfile | 17 +++++++++++++++++ scripts/build.sh | 4 ++++ scripts/run.sh | 4 ++++ 3 files changed, 25 insertions(+) create mode 100644 scripts/Dockerfile create mode 100644 scripts/build.sh create mode 100644 scripts/run.sh diff --git a/scripts/Dockerfile b/scripts/Dockerfile new file mode 100644 index 00000000000..888a811aded --- /dev/null +++ b/scripts/Dockerfile @@ -0,0 +1,17 @@ +# Use the official Jekyll image from Docker Hub +FROM jekyll/jekyll:latest + +# Set the working directory +WORKDIR /srv/jekyll + +# Copy the current directory contents into the container at /srv/jekyll +COPY . /srv/jekyll + +# Install any needed packages specified in Gemfile +RUN bundle install + +# Expose port 4000 to the host +EXPOSE 4000 + +# Run Jekyll server +CMD ["jekyll", "serve", "--host", "0.0.0.0"] diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 00000000000..d4622fae4d8 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Build the Docker image +docker build -t my-jekyll-site -f scripts/Dockerfile . diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100644 index 00000000000..d1036ecb49c --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Run the Docker container +docker run --rm -v "$PWD:/srv/jekyll" -p 4000:4000 my-jekyll-site