diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..634b37d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.gitignore +.dockerignore +_site/ +.bundle/README.md \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..1de8508 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,40 @@ +# Stage 1: The Builder Environment +FROM ruby:3.2.2 AS builder + +# Set the working directory inside the container +WORKDIR /usr/src/app + +# Install dependencies required to build the site +# Try Alpine's apk first; fall back to Debian's apt-get if apk isn't available. +RUN set -eux; \ + if command -v apk >/dev/null 2>&1; then \ + apk add --no-cache build-base; \ + elif command -v apt-get >/dev/null 2>&1; then \ + apt-get update && apt-get install -y build-essential; \ + else \ + echo 'No supported package manager found (apk or apt-get)'; exit 1; \ + fi + +# Copy the Gemfile and Gemfile.lock to leverage Docker's layer caching +COPY Gemfile Gemfile.lock ./ + +# Install the Ruby gems +RUN bundle install + +# Copy the rest of the application source code +COPY . . + +# Build the Jekyll site. The output will be in the /usr/src/app/_site directory. +RUN bundle exec jekyll build + +# --- + +# Stage 2: The Production Environment +# We use a lightweight Nginx image to serve the static files. +FROM nginx:alpine + +# Copy the built static site from the 'builder' stage +COPY --from=builder /usr/src/app/_site /usr/share/nginx/html + +# Expose port 80 to allow traffic to the web server +EXPOSE 80 diff --git a/Gemfile b/Gemfile index 053c27d..3b86743 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,5 @@ source 'https://rubygems.org' -gem 'github-pages' + +gem 'github-pages', '~> 232' + +ruby '3.2.2' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 4fee41d..fce50b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,9 +2,8 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) - activesupport (4.2.6) + activesupport (4.2.11.3) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) @@ -89,7 +88,6 @@ GEM gemoji (~> 2.0) html-pipeline (~> 2.2) jekyll (>= 2.0) - json (1.8.3) kramdown (1.10.0) liquid (3.0.6) listen (3.0.6) @@ -132,4 +130,4 @@ DEPENDENCIES github-pages BUNDLED WITH - 1.11.2 + 2.7.2