diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9dc07726657..882968f2642 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,6 +20,13 @@ If you'd like to edit a specific devopsdays event site (and/or contribute code), 1. Start docker 1. Run `./hugoserver.sh` from the root of this repo. +#### Run Hugo using docker compose + +1. Start your containerisation engine (Colima, Docker, etc.) +1. Run `make docker-server` from the root of this repo. + +Hugo and Node versions are read automatically from `.github/workflows/hugo.yml`. + #### Run Hugo locally 1. Install [Hugo](http://gohugo.io). Use the Hugo version that we use in [.github/workflows/hugo.yml](https://github.com/devopsdays/devopsdays-web/blob/main/.github/workflows/hugo.yml) file. [(Quick Install)](https://gohugo.io/getting-started/installing#binary-cross-platform) diff --git a/makefile b/makefile index 1d1b35efce6..f26fb5f5dd5 100644 --- a/makefile +++ b/makefile @@ -1,19 +1,27 @@ -.PHONY: deps build server clean - -# Copy dependencies from node_modules to assets -deps: - ./utilities/build-scripts/copy-scss-deps.sh - ./utilities/build-scripts/copy-js-deps.sh - -# Build the site -build: deps - hugo - -# Run the development server -server: deps - hugo server - -# Clean up generated files -clean: - rm -rf public/ - rm -rf resources/ +.PHONY: deps build server clean docker-server + +HUGO_VERSION := $(shell grep 'HUGO_VERSION:' .github/workflows/hugo.yml | sed 's/.*: //') +NODE_VERSION := $(shell grep 'NODE_VERSION:' .github/workflows/hugo.yml | sed 's/.*: //') + +# Copy dependencies from node_modules to assets +deps: + ./utilities/build-scripts/copy-scss-deps.sh + ./utilities/build-scripts/copy-js-deps.sh + +# Build the site +build: deps + hugo + +# Run the development server +server: deps + hugo server + +# Run the development server via Docker (versions sourced from .github/workflows/hugo.yml) +docker-server: + NODE_VERSION=$(NODE_VERSION) HUGO_VERSION=$(HUGO_VERSION) \ + docker compose -f utilities/contrib/docker-compose.yml up + +# Clean up generated files +clean: + rm -rf public/ + rm -rf resources/ diff --git a/utilities/contrib/docker-compose.yml b/utilities/contrib/docker-compose.yml new file mode 100644 index 00000000000..45f7f684ee3 --- /dev/null +++ b/utilities/contrib/docker-compose.yml @@ -0,0 +1,19 @@ +# docker compose -f utilities/contrib/docker-compose.yml up +services: + hugo: + build: + dockerfile: ../../.devcontainer/Dockerfile + args: + NODE_VERSION: "${NODE_VERSION:?NODE_VERSION must be set - run via make docker-server}" + VARIANT: hugo_extended + VERSION: "${HUGO_VERSION:?HUGO_VERSION must be set - run via make docker-server}" + working_dir: /workspace + volumes: + - ../../:/workspace + - node_modules:/workspace/node_modules + ports: + - "1313:1313" + command: sh -c "npm install && make deps && hugo server --bind 0.0.0.0 --poll 1s" + +volumes: + node_modules: