Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Docker #1488

Merged
merged 9 commits into from May 4, 2024
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
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
@@ -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
@@ -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
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.
UlisesGascon marked this conversation as resolved.
Show resolved Hide resolved

## Formatting

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