-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2296 from johnny-morrice/feature/master-build
Dockerized build scripts for the master branch
- Loading branch information
Showing
10 changed files
with
173 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Build & Deploy to Cloudflare | ||
|
||
on: | ||
# 1. Manual trigger via the Actions tab | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "Branch to build and deploy" | ||
required: false | ||
default: "master" | ||
inputs: | ||
environment: | ||
description: "Environment to deploy to" | ||
required: false | ||
default: "development" | ||
|
||
jobs: | ||
build-and-deploy: | ||
name: Build and Deploy to Cloudflare | ||
runs-on: ubuntu-latest | ||
|
||
# 2. Use the environment input to set the environment | ||
# so that environment-scoped secrets are available | ||
environment: ${{ github.event.inputs.environment }} | ||
|
||
steps: | ||
# 3. Check out the specified branch | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.event.inputs.branch }} | ||
|
||
# 4. Build the site using your existing Docker build script | ||
- name: Build the site using Docker | ||
run: | | ||
./scripts/build.sh | ||
# 5. Deploy to Cloudflare using the Cloudflare Wrangler Action | ||
- name: Deploy | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
environment: ${{ github.event.inputs.environment }} | ||
workingDirectory: "_site" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM jekyll/jekyll:4.0 | ||
|
||
# Create a working directory. | ||
WORKDIR /srv/jekyll | ||
|
||
# Copy dependency files first for caching. | ||
COPY Gemfile ./ | ||
|
||
# Make files be owned by jekyll user. | ||
RUN chown -R jekyll:jekyll /srv/jekyll | ||
|
||
# Update the bundle and add the current platform lock. | ||
RUN bundle lock | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Use Ruby 3.1 series on Alpine. | ||
FROM ruby:3.1-alpine | ||
|
||
# Install system dependencies. | ||
# (Node.js is here for asset compilation, adjust as needed.) | ||
RUN apk update && apk add --no-cache \ | ||
build-base \ | ||
nodejs \ | ||
libffi-dev | ||
|
||
# Install bundler if it’s not already available. | ||
RUN gem install bundler -v 2.3.25 | ||
|
||
# Set working directory. | ||
WORKDIR /srv/jekyll | ||
|
||
# Copy Gemfiles (so that dependencies are installed during image build). | ||
COPY Gemfile Gemfile.lock ./ | ||
|
||
# Install Ruby dependencies as specified in the Gemfile. | ||
RUN bundle install | ||
|
||
# Copy the rest of the project files. | ||
# When running interactively you will mount your project folder over this. | ||
COPY . . | ||
|
||
# Expose the default Jekyll port. | ||
EXPOSE 4000 | ||
|
||
ENV JEKYLL_ENV=docker | ||
|
||
# Run the Jekyll server with incremental rebuilds and bind to localhost. | ||
CMD ["bundle", "exec", "jekyll", "serve", "--incremental", "--host", "0.0.0.0", "--config", "_config_docker.yml"] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# A sample Gemfile | ||
source "https://rubygems.org" | ||
|
||
gem "jekyll" | ||
ruby '~> 3.1.1' | ||
gem "jekyll", "~> 4.3.3" | ||
|
||
gem "jekyll-sass-converter", "~> 2.0" | ||
gem "webrick", "~> 1.8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Site settings | ||
title: argmin gravitas | ||
fmtTitle: argmin gravitas | ||
email: g@gleech.org | ||
baseurl: "" # the subpath of your site, e.g. /blog/ | ||
url: http://localhost:4000 # the base hostname & protocol for your site | ||
github_username: g-leech | ||
highlighter: none | ||
|
||
# Build settings | ||
markdown: kramdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Building Docker image for static site generation..." | ||
docker build --platform=linux/amd64 -t argmin-gravitas/jekyll-dev -f Dockerfiles/Dockerfile.jekyll . | ||
|
||
echo "Generating static site..." | ||
# Mount your local "./_site" directory to the container's /srv/jekyll/_site directory. | ||
mkdir -p _site | ||
docker run --platform=linux/amd64 -v "$(pwd)/_site:/srv/jekyll/_site" argmin-gravitas/jekyll-dev bundle exec jekyll build | ||
|
||
echo "Site built successfully into the ./_site directory." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Define image name and Dockerfile path. | ||
IMAGE_NAME="gemfile_updater" | ||
DOCKERFILE="Dockerfiles/Dockerfile.bundle" | ||
|
||
echo "Building the Docker image" | ||
docker build -t ${IMAGE_NAME} -f ${DOCKERFILE} . | ||
|
||
# Create a container from the builder image. | ||
CONTAINER_ID=$(docker create ${IMAGE_NAME}) | ||
|
||
# Copy the Gemfile.lock from the container to the host. | ||
echo "Copying updated Gemfile.lock from container (${CONTAINER_ID})..." | ||
docker cp "${CONTAINER_ID}:/srv/jekyll/Gemfile.lock" ./Gemfile.lock | ||
|
||
# Clean up the temporary container. | ||
docker rm ${CONTAINER_ID} > /dev/null | ||
|
||
echo "Updated Gemfile.lock has been copied to the host." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "Building Docker image for Jekyll development..." | ||
docker build -t argmin-gravitas/jekyll-dev -f Dockerfiles/Dockerfile.jekyll . | ||
|
||
echo "Running Docker container with live file editing enabled..." | ||
# The -v flag mounts the current directory (source code) into /srv/jekyll in the container. | ||
docker run -p 4000:4000 -v "$(pwd)":/srv/jekyll argmin-gravitas/jekyll-dev |