diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..9e52c947 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,8 @@ +.git +.github +.bundle +vendor +_site +.jekyll-metadata +.jekyll-cache +Gemfile.lock diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 1df962cb..515b81c3 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,18 +24,18 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v7 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v4 with: languages: ${{ matrix.language }} queries: +security-and-quality - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v4 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v4 with: category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index 0acdfbf1..125a1c48 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -32,16 +32,16 @@ jobs: runs-on: ubuntu-22.04 steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Setup Ruby - uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0 + uses: ruby/setup-ruby@003a5c4d8d6321bd302e38f6f0ec593f77f06600 # v1.319.0 with: ruby-version: '3.1' # Not needed with a .ruby-version file bundler-cache: true # runs 'bundle install' and caches installed gems automatically cache-version: 0 # Increment this number if you need to re-download cached gems - name: Setup Pages id: pages - uses: actions/configure-pages@v5 + uses: actions/configure-pages@v6 - name: Build with Jekyll # Outputs to the './_site' directory by default run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" @@ -49,7 +49,7 @@ jobs: JEKYLL_ENV: production - name: Upload artifact # Automatically uploads an artifact from the './_site' directory by default - uses: actions/upload-pages-artifact@v3 + uses: actions/upload-pages-artifact@v5 # Deployment job deploy: @@ -61,4 +61,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v5 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ffc0c69a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,46 @@ +# Dockerfile to build and preview the GeoNode Jekyll website locally. +# +# Build the image: +# docker build -t geonode-site . +# +# Preview at http://localhost:4000: +# docker run --rm -p 4000:4000 geonode-site +# +# Live-reload while editing (mount the working tree): +# docker run --rm -p 4000:4000 -v "$PWD":/site geonode-site +# +# Build only, writing the static site to ./_site (no server): +# docker run --rm -v "$PWD":/site geonode-site bundle exec jekyll build + +FROM ruby:3.3-slim + +# System packages required to build native gem extensions (nokogiri, ffi, ...) +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + build-essential \ + git \ + && rm -rf /var/lib/apt/lists/* + +# Install gems from a directory OUTSIDE the site tree, and point Bundler at it. +# This way, bind-mounting the working tree over /site for live-reload cannot +# shadow the Gemfile/Gemfile.lock, nor make Bundler resolve against a stale +# host Gemfile.lock. Gems live in /usr/local/bundle (the base image default). +ENV BUNDLE_GEMFILE=/deps/Gemfile +WORKDIR /deps +COPY Gemfile ./ +RUN gem install bundler \ + && bundle install + +# Site content. Bundler still reads the Gemfile from /deps (BUNDLE_GEMFILE), +# so the copied/mounted files here are treated purely as Jekyll sources. +WORKDIR /site +COPY . . + +EXPOSE 4000 + +# --host 0.0.0.0 so the server is reachable from the host; --force_polling +# makes live-reload work reliably with mounted volumes. +CMD ["bundle", "exec", "jekyll", "serve", \ + "--host", "0.0.0.0", \ + "--port", "4000", \ + "--force_polling"] diff --git a/Gemfile b/Gemfile index 98b5122d..9ecdae07 100644 --- a/Gemfile +++ b/Gemfile @@ -4,5 +4,5 @@ source "https://rubygems.org" # gem "rails" -gem "github-pages", "~> 231", group: :jekyll_plugins +gem "github-pages", "~> 232", group: :jekyll_plugins gem "webrick", "~> 1.8" diff --git a/README.md b/README.md index 5f309a3d..cadefee2 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,110 @@ # geonode.org -Prerequisites -------------- - sudo apt-get install ruby-full build-essential zlib1g-dev - echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc - echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc - echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc - source ~/.bashrc - gem install bundler - bundle install - -Workflow --------- - - # edit content - bundle exec jekyll serve # default port is 4000, set explicitly with -P - # view at http://localhost:4000 - # adding blogposts - cd _drafts - vi newpost.md - # make sure to set the following YAML front matter: - # layout: base - # - # preview with `jekyll build --drafts` or `jekyll serve --drafts` and draft will show up as latest post - # when you are ready to publish: - # - rename the file as per the current YYYY-MM-DD - git mv _drafts/newpost.md _posts/YYYY-MM-DD-newpost.md - vi _posts/YYYY-MM-DD-newpost.md - # commit and push - bundle exec jekyll build - git commit -m 'publish article' - git push origin master +Source for the [GeoNode](https://geonode.org) project website, a static site built with [Jekyll](https://jekyllrb.com/) and served at [geonode.org](https://geonode.org). + +## How it's published + +The site is built and deployed automatically by GitHub Actions (`.github/workflows/jekyll.yml`): every push to the `master` branch runs `jekyll build` and deploys the result to GitHub Pages. There is no manual publish step — merging to `master` is what ships the site. + +The build uses the gems pinned in this repo's `Gemfile`. The site tracks the [`github-pages`](https://github.com/github/pages-gem) gem, which keeps Jekyll and its plugins aligned with what GitHub Pages supports (currently Jekyll 3.x). + +## Local development + +You can run the site either with Docker (no Ruby toolchain needed on your machine) or with a native Ruby setup. + +### Option A — Docker (recommended) + +Build the image once: + +```bash +docker build -t geonode-site . +``` + +Serve the site at : + +```bash +docker run --rm -p 4000:4000 geonode-site +``` + +Serve with live-reload while editing, by mounting the working tree: + +```bash +docker run --rm -p 4000:4000 -v "$PWD":/site geonode-site +``` + +Build only and extract the generated static site to `./_site` (no server): + +```bash +docker run --rm -v "$PWD":/site geonode-site bundle exec jekyll build +``` + +> On Linux/WSL the generated files are owned by `root`. To have them owned by +> your user, add `--user "$(id -u):$(id -g)"` to the `docker run` command. + +### Option B — Native Ruby + +Install the prerequisites (Debian/Ubuntu example): + +```bash +sudo apt-get install ruby-full build-essential zlib1g-dev +``` + +If gems fail to install globally, install them under your home directory: + +```bash +echo '# Install Ruby gems to ~/gems' >> ~/.bashrc +echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc +echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc +source ~/.bashrc +``` + +Install the project gems and serve the site: + +```bash +gem install bundler +bundle install +bundle exec jekyll serve # default port 4000; override with -P +``` + +View at . + +## Writing a blog post + +Drafts live in `_drafts/` and are excluded from production builds. + +1. Create the draft and set its YAML front matter: + + ```bash + cd _drafts + vi newpost.md + ``` + + ```yaml + --- + layout: base + --- + ``` + +2. Preview drafts (they show up as the latest post): + + ```bash + bundle exec jekyll serve --drafts + # or, with Docker: + docker run --rm -p 4000:4000 -v "$PWD":/site geonode-site \ + bundle exec jekyll serve --host 0.0.0.0 --drafts + ``` + +3. When ready to publish, move the draft into `_posts/` with a dated filename: + + ```bash + git mv _drafts/newpost.md _posts/YYYY-MM-DD-newpost.md + vi _posts/YYYY-MM-DD-newpost.md + ``` + +4. Commit and push to `master` — the GitHub Actions workflow builds and + deploys the site automatically: + + ```bash + git commit -am 'publish article' + git push origin master + ``` diff --git a/_config.yml b/_config.yml index 9c19ea88..1f9a2d1e 100644 --- a/_config.yml +++ b/_config.yml @@ -21,13 +21,9 @@ defaults: layout: 'base.html' gems: -#- jekyll-feed - jekyll-mentions - jekyll-sitemap -#feed: -# path: blog/feed.xml - exclude: [README.md, vendor, LICENSE.txt, CNAME] # Markdown Configuration @@ -45,7 +41,7 @@ extbase: dns_prefetch: ['//www.google-analytics.com', '//fonts.googleapis.com'] -fonts: ['Lato:300,400,700', 'Inconsolata'] +# Fonts are loaded directly in _layouts/base.html (Google Fonts css2 API). keywords: - GeoNode diff --git a/_includes/footer.html b/_includes/footer.html index 581301e6..e8c89592 100644 --- a/_includes/footer.html +++ b/_includes/footer.html @@ -1,21 +1,15 @@ -