Skip to content

Commit

Permalink
Add support for Docker (#1488)
Browse files Browse the repository at this point in the history
* chore: add a Dockerfile

* chore: add a Makefile to support Docker operations

* docs: update documentation to include Docker support

* ci: add step to check Docker build

* fix: typo in docker image reference

* docs: add information about make help

* docs: update docker documentation to use advance md features

Co-authored-by: David Lakin <[email protected]>

* update the make serve log message to have URL

* update to newer jekyll docker image for ruby version

---------
Co-authored-by: Ulises Gascón <[email protected]>
Co-authored-by: David Lakin <[email protected]>
Co-authored-by: Jon Church <[email protected]>
  • Loading branch information
3 people authored May 4, 2024
1 parent 2078c57 commit d76b2bd
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,9 @@ jobs:
- name: Run tests
shell: bash
run: npm test

- name: Check Docker support
shell: bash
run: |
docker --version
make build
23 changes: 23 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Use the official Jekyll image as the base
FROM jekyll/jekyll:4.2.2

# Set the working directory
WORKDIR /usr/src/app

# Change the permissions of the working directory
RUN chmod 777 /usr/src/app

# Copy the Gemfile into the image
COPY Gemfile ./

# Install the gems and delete the Gemfile.lock
RUN bundle install --no-cache && rm Gemfile.lock

# Copy the rest of the project into the image
COPY . .

# Expose the port Jekyll will run on
EXPOSE 4000

# The default command to run Jekyll
CMD ["jekyll", "serve", "--host", "0.0.0.0", "--livereload"]
27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
GREEN := \033[1;32m
BLUE := \033[1;34m
RESET := \033[0m

# The directory of this file
DIR := $(shell echo $(shell cd "$(shell dirname "${BASH_SOURCE[0]}" )" && pwd ))

# This will output the help for each task
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
.PHONY: help

help: ## This help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "${GREEN}%-30s${RESET} %s\n", $$1, $$2}' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help

serve: ## Local server
@echo "${BLUE}Starting expressjs.com at http://localhost:4000${RESET}"
docker run -p 4000:4000 -p 35729:35729 -v $(DIR):/usr/src/app expressjs.com

build: ## Build site
@echo "${BLUE}Building site...${RESET}"
docker build -t expressjs.com .

clean: ## Clean up
@echo "${BLUE}Clean up...${RESET}"
docker rmi expressjs.com
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ To preview the website locally:

Then, load <http://localhost:4000> in your browser.

## Local Setup using Docker

>[!TIP]
> You can run `make help` to obtain detailed information on how to use our make commands.
0. Ensure that you have Docker and Make installed.
1. Run `make build` to build the project.
2. Run `make serve` to serve the project, this include live reloading so any change will be reflected (it can take a while, check the logs).
3. Run `make clean` to remove the docker images and resources generated.

## Formatting

Jekyll uses a variant of Markdown known as [Kramdown](https://kramdown.gettalong.org/quickref.html).
Expand Down

0 comments on commit d76b2bd

Please sign in to comment.