diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..047f6f6 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,14 @@ +.git +.gitignore +_site +node_modules +vendor +.bundle +.jekyll-cache +.sass-cache +.task +public +assets/fonts +assets/js +README.markdown +compose.podman.yaml diff --git a/.gitignore b/.gitignore index 8ee6b71..a8b34af 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,10 @@ _site _posts _data/activity_pub.yml .env +privkey.pem +pack.js .bundle/ +.pnpm-store/ .jekyll-cache/ .sass-cache/ .task/ diff --git a/README.markdown b/README.markdown index dbd1d2b..1fa178c 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,106 @@ -# Sutty Base Bootstrap 5 +# Co-op Cloud Website -Re-escritura de -[sutty-base-jekyll-theme](https://0xacab.org/sutty/jekyll/sutty-base-jekyll-theme) -con soporte para Bootstrap 5. +Jekyll site and theme for the **Co-op Cloud Federation**, based on +[Sutty Base Bootstrap 5](https://0xacab.org/sutty/jekyll/sutty-base-jekyll-theme). + +- Testing site: +- Deployment: **Sutty** +- Local development: **Docker Compose** + +## What is in this repository + +This repository contains both the theme and the site content: + +- **Jekyll 4.4** with **Bootstrap 5** +- English content in `_en/` and Spanish content in `_es/` (only English is + currently enabled) +- Page layouts in `_layouts/` and reusable components in `_includes/` +- Custom plugins in `_plugins/`, including generated recipe and taxonomy pages +- Static search with **Pagefind** +- **ActivityPub** support through `jekyll-activity-pub` +- JavaScript built with **esbuild**, Stimulus, and Turbo + +Content is normally written in the Sutty CMS, which commits to this repository. + +## Run locally with Docker + +Requirements: + +- Docker with Compose v2, or Podman with `podman-compose` +- Git LFS + +```sh +git lfs install +git lfs pull +docker compose up --build +``` + +Open . + +The first run takes a few minutes because it installs gems, compiles native +extensions, and builds the site. + +With rootless Podman: + +```sh +podman-compose -f compose.yaml -f compose.podman.yaml up --build +``` + +Docker is for local development only. It does **not** deploy the site. + +## Common commands + +```sh +docker compose logs -f # follow logs +docker compose down # stop +docker compose down -v # stop and reset dependencies +docker compose run --rm setup # reinstall after dependency changes +``` + +One-off build: + +```sh +docker compose run --rm jekyll \ + bundle exec jekyll build --config _config.yml,_config.docker.yml +``` + +## Repository layout + +```text +_en/, _es/ Site content +_data/ CMS schemas, translations, recipe data +_layouts/ Page templates +_includes/ Reusable Liquid components +_plugins/ Custom Jekyll plugins +_sass/, assets/ Styles, fonts, and JavaScript +docker/dev/ Docker image, setup script, and dev Gemfile +compose.yaml Local development environment +_config.yml Jekyll configuration +``` + +## Notes + +- The production `Gemfile.lock` uses Sutty's gem server and musl-native gems + that are not available on rubygems.org. The Docker setup therefore uses a + separate `docker/dev/Gemfile` and lockfile. Some versions may differ from + production. +- Fonts, images, `assets/js/pack.*`, and `_bin/pagefind` are stored with Git + LFS. The site will not build correctly without `git lfs pull`. +- The setup service generates `privkey.pem` and `pack.js`. Do not commit + `privkey.pem`. +- The Fork Awesome subset is committed. Regenerate it with + `./_bin/subset_fork_awesome.sh` after changing `_data/fa.yml`, then commit it. +- Change `pack.js` only through the `js` service; edit sources in `_packs/`. + +## Troubleshooting + +- **LFS error during setup:** run `git lfs pull`. +- **Connection refused from another machine:** the server listens on + `0.0.0.0:4000`; allow TCP ports `4000` and `35729` in the host firewall. +- **Port already in use:** change the host ports in `compose.yaml`. +- **Broken dependency state:** run `docker compose down -v` and start again. + +## License + +The theme is distributed under the Anti-Fascist MIT License. See +[`LICENSE.txt`](LICENSE.txt). diff --git a/_config.docker.yml b/_config.docker.yml new file mode 100644 index 0000000..86f604b --- /dev/null +++ b/_config.docker.yml @@ -0,0 +1,22 @@ +url: "http://localhost:4000" +hostname: "localhost:4000" +# Jekyll replaces arrays when merging configs, so this repeats the main +# exclude list and adds development-only paths. +exclude: + - .bundle + - .jekyll-cache + - .pnpm-store + - .sass-cache + - .task + - Dockerfile + - Gemfile + - Gemfile.lock + - README.markdown + - _data/activity_pub.yml + - compose.podman.yaml + - compose.yaml + - docker + - gemfiles + - node_modules + - privkey.pem + - vendor diff --git a/_config.yml b/_config.yml index 059996c..d77c8bf 100644 --- a/_config.yml +++ b/_config.yml @@ -78,3 +78,20 @@ url: https://coopcloud.testing.sutty.nl brotli: quality: 9 name: coopcloud.testing +exclude: +- .bundle +- .jekyll-cache +- .pnpm-store +- .sass-cache +- .task +- Dockerfile +- Gemfile +- Gemfile.lock +- README.markdown +- compose.podman.yaml +- compose.yaml +- docker +- gemfiles +- node_modules +- privkey.pem +- vendor diff --git a/assets/fonts/forkawesome-webfont.woff2 b/assets/fonts/forkawesome-webfont.woff2 new file mode 100644 index 0000000..3e536bf --- /dev/null +++ b/assets/fonts/forkawesome-webfont.woff2 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0bfeab291982ae425d92b0fc1b4d39bb0ded8827c95b3387d4a28dd6381c8e5a +size 712 diff --git a/compose.podman.yaml b/compose.podman.yaml new file mode 100644 index 0000000..34e0f10 --- /dev/null +++ b/compose.podman.yaml @@ -0,0 +1,15 @@ +# Podman-only override. +# +# Rootless Podman maps container root to a subordinate UID, so the bind-mounted +# source is not writable by the default container user. Keep the host UID and +# GID inside the container instead: +# +# podman-compose -f compose.yaml -f compose.podman.yaml up --build +# +services: + setup: + userns_mode: keep-id + jekyll: + userns_mode: keep-id + js: + userns_mode: keep-id diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..2cd50b4 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,68 @@ +name: coopcloud-website + +x-app: &app + build: + context: . + dockerfile: docker/dev/Dockerfile + image: coopcloud-website-dev + working_dir: /srv/site + volumes: + - .:/srv/site:z + - bundle:/srv/site/vendor/bundle + - node_modules:/srv/site/node_modules + - site:/srv/site/_site + environment: + BUNDLE_APP_CONFIG: /srv/site/.bundle + BUNDLE_GEMFILE: /srv/site/docker/dev/Gemfile + BUNDLE_PATH: /srv/site/vendor/bundle + GEMS_SOURCE: https://rubygems.org + HAINISH: "" + HOME: /tmp + JEKYLL_ENV: development + +services: + setup: + <<: *app + command: ["sh", "/srv/site/docker/dev/setup.sh"] + restart: "no" + + jekyll: + <<: *app + command: + - bundle + - exec + - jekyll + - serve + - --host + - 0.0.0.0 + - --port + - "4000" + - --livereload + - --watch + - --config + - _config.yml,_config.docker.yml + depends_on: + setup: + condition: service_completed_successfully + ports: + - "4000:4000" + - "35729:35729" + + js: + <<: *app + command: + - pnpm + - exec + - esbuild + - _packs/entry.js + - --bundle + - --outfile=pack.js + - --watch=forever + depends_on: + setup: + condition: service_completed_successfully + +volumes: + bundle: + node_modules: + site: diff --git a/docker/dev/Dockerfile b/docker/dev/Dockerfile new file mode 100644 index 0000000..c2e8edb --- /dev/null +++ b/docker/dev/Dockerfile @@ -0,0 +1,42 @@ +# syntax=docker/dockerfile:1 +FROM docker.io/library/ruby:3.1.5-alpine3.18 + +RUN apk add --no-cache \ + bash \ + brotli-dev \ + build-base \ + ca-certificates \ + curl \ + file \ + file-dev \ + git \ + git-lfs \ + nodejs \ + npm \ + openssl \ + py3-pip \ + python3 \ + tini \ + vips-dev \ + && npm install -g pnpm@9 \ + && python3 -m pip install --no-cache-dir fonttools brotli \ + && gem install bundler --version 2.6.9 --no-document \ + && rm -rf /var/cache/apk/* + +WORKDIR /srv/site + +# Keep UIDs aligned with the common host UID so bind-mounted files and +# dependency volumes remain writable. +RUN addgroup -g 1000 app \ + && adduser -D -u 1000 -G app app \ + && mkdir -p /srv/site/_site /srv/site/vendor/bundle /srv/site/node_modules \ + && chown -R 1000:1000 /srv/site + +ENV HOME=/tmp \ + BUNDLE_APP_CONFIG=/srv/site/.bundle \ + BUNDLE_PATH=/srv/site/vendor/bundle + +USER app + +ENTRYPOINT ["/sbin/tini", "--"] +CMD ["sh"] diff --git a/docker/dev/Gemfile b/docker/dev/Gemfile new file mode 100644 index 0000000..d671ed5 --- /dev/null +++ b/docker/dev/Gemfile @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +# Development-only Gemfile. +# +# The production lockfile is built against the private Sutty gem source and +# pinned to musl-native gems such as ruby-brs. That source is not reachable +# from outside Sutty, so the Docker environment resolves the same dependencies +# from rubygems.org into its own lockfile. +ENV['GEMS_SOURCE'] = 'https://rubygems.org' + +eval_gemfile File.expand_path('../../Gemfile', __dir__) diff --git a/docker/dev/Gemfile.lock b/docker/dev/Gemfile.lock new file mode 100644 index 0000000..fb79cef --- /dev/null +++ b/docker/dev/Gemfile.lock @@ -0,0 +1,332 @@ +GEM + remote: https://rubygems.org/ + specs: + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + adsp (1.0.10) + ansi (1.6.0) + ast (2.4.3) + base64 (0.3.0) + bigdecimal (3.1.9) + brotli (0.9.2) + climate_control (1.2.0) + coderay (1.1.3) + colorator (1.1.0) + concurrent-ruby (1.3.8) + crass (1.0.8) + csv (3.3.7) + distributed-press-api-client (0.5.4) + addressable (~> 2.3, >= 2.3.0) + climate_control + dry-schema + httparty (~> 0.18) + httparty-cache (~> 0.0.6) + json (~> 2.1, >= 2.1.0) + jwt (~> 2.6.0) + nokogiri (~> 1.16) + dry-configurable (1.3.0) + dry-core (~> 1.1) + zeitwerk (~> 2.6) + dry-core (1.1.0) + concurrent-ruby (~> 1.0) + logger + zeitwerk (~> 2.6) + dry-inflector (1.2.0) + dry-initializer (3.2.0) + dry-logic (1.6.0) + bigdecimal + concurrent-ruby (~> 1.0) + dry-core (~> 1.1) + zeitwerk (~> 2.6) + dry-schema (1.14.1) + concurrent-ruby (~> 1.0) + dry-configurable (~> 1.0, >= 1.0.1) + dry-core (~> 1.1) + dry-initializer (~> 3.2) + dry-logic (~> 1.5) + dry-types (~> 1.8) + zeitwerk (~> 2.6) + dry-types (1.8.3) + bigdecimal (~> 3.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0) + dry-inflector (~> 1.0) + dry-logic (~> 1.4) + zeitwerk (~> 2.6) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb (~> 0) + eventmachine (1.2.7) + faraday (1.10.6) + faraday-em_http (~> 1.0) + faraday-em_synchrony (~> 1.0) + faraday-excon (~> 1.1) + faraday-httpclient (~> 1.0) + faraday-multipart (~> 1.0) + faraday-net_http (~> 1.0) + faraday-net_http_persistent (~> 1.0) + faraday-patron (~> 1.0) + faraday-rack (~> 1.0) + faraday-retry (~> 1.0) + ruby2_keywords (>= 0.0.4) + faraday-em_http (1.0.0) + faraday-em_synchrony (1.0.1) + faraday-excon (1.1.0) + faraday-http-cache (2.5.1) + faraday (>= 0.8) + faraday-httpclient (1.0.1) + faraday-multipart (1.2.0) + multipart-post (~> 2.0) + faraday-net_http (1.0.2) + faraday-net_http_persistent (1.2.0) + faraday-patron (1.0.0) + faraday-rack (1.0.0) + faraday-retry (1.0.4) + faraday_middleware (1.2.1) + faraday (~> 1.0) + fast_blank (1.0.1) + ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x86_64-darwin) + ffi (1.17.4-x86_64-linux-musl) + forwardable-extended (2.6.0) + google-protobuf (4.35.1-arm64-darwin) + bigdecimal + rake (~> 13.3) + google-protobuf (4.35.1-x86_64-darwin) + bigdecimal + rake (~> 13.3) + google-protobuf (4.35.1-x86_64-linux-musl) + bigdecimal + rake (~> 13.3) + http_parser.rb (0.8.1) + httparty (0.24.3) + csv + mini_mime (>= 1.0.0) + multi_xml (>= 0.5.2) + httparty-cache (0.0.6) + httparty (~> 0.18) + i18n (1.15.2) + concurrent-ruby (~> 1.0) + io-console (0.9.5) + jekyll (4.4.1) + addressable (~> 2.4) + base64 (~> 0.2) + colorator (~> 1.0) + csv (~> 3.0) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (>= 2.0, < 4.0) + jekyll-watch (~> 2.0) + json (~> 2.6) + kramdown (~> 2.3, >= 2.3.1) + kramdown-parser-gfm (~> 1.0) + liquid (~> 4.0) + mercenary (~> 0.3, >= 0.3.6) + pathutil (~> 0.9) + rouge (>= 3.0, < 5.0) + safe_yaml (~> 1.0) + terminal-table (>= 1.8, < 4.0) + webrick (~> 1.7) + jekyll-activity-pub (0.3.6) + distributed-press-api-client (~> 0.5.0) + jekyll (~> 4) + marcel (~> 1) + jekyll-brotli (2.4.1) + brotli (~> 0.2) + jekyll (>= 3.0, < 5.0) + jekyll-data (1.1.1) + jekyll (>= 3.3, < 5.0.0) + jekyll-drafts-as-metadata (0.0.6) + jekyll (>= 3.8, < 5) + jekyll-embed-urls (0.6.6) + faraday (~> 1.3) + faraday-http-cache (~> 2.2) + faraday_middleware (~> 1) + jekyll (~> 4) + loofah (~> 2.9) + ogp (~> 0.5.0, < 0.6) + ruby-oembed (>= 0.16.0) + url-privacy (~> 0.1.1) + jekyll-gzip (2.5.1) + jekyll (>= 3.0, < 5.0) + jekyll-hardlinks (0.2.0) + jekyll (~> 4) + jekyll-ignore-layouts (0.1.2) + jekyll (~> 4) + jekyll-images (0.4.7) + jekyll (~> 4) + ruby-filemagic (~> 0.7) + ruby-vips (~> 2) + jekyll-include-cache (0.3.1) + jekyll (>= 3.7, < 5.0) + jekyll-linked-posts (0.6.0) + jekyll (~> 4) + jekyll-locales (0.3.0) + jekyll-logger-tap (0.2.0) + jekyll (~> 4.2) + jekyll-nokogiri (0.1.0) + jekyll + nokogiri + jekyll-order (0.1.7) + jekyll-raw-html-converter (0.0.1) + jekyll (~> 4) + jekyll-relative-urls (0.0.7) + jekyll (~> 4) + jekyll-sass-converter (3.1.0) + sass-embedded (~> 1.75) + jekyll-seo-tag (2.9.1) + jekyll (>= 3.8, < 5.0) + jekyll-sitemap (1.4.0) + jekyll (>= 3.7, < 5.0) + jekyll-watch (2.2.1) + listen (~> 3.0) + json (2.21.2) + jwt (2.6.0) + kramdown (2.5.2) + rexml (>= 3.4.4) + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) + language_server-protocol (3.17.0.6) + liquid (4.0.4) + listen (3.10.1) + logger + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + logger (1.7.0) + loofah (2.25.2) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + marcel (1.2.1) + mercenary (0.4.0) + method_source (1.1.0) + mini_mime (1.1.5) + multi_xml (0.7.1) + bigdecimal (~> 3.1) + multipart-post (2.4.1) + nokogiri (1.18.10-arm64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.18.10-x86_64-linux-musl) + racc (~> 1.4) + oga (3.5) + ast + ruby-ll (~> 2.2) + ogp (0.5.0) + oga (~> 3.3) + parallel (1.28.0) + parser (3.3.13.0) + ast (~> 2.4.1) + racc + pathutil (0.16.2) + forwardable-extended (~> 2.6) + prism (1.9.0) + prometheus_exporter (2.2.0) + webrick + pry (0.16.1) + coderay (~> 1.1) + method_source (~> 1.0) + reline (>= 0.6.0) + public_suffix (6.0.2) + racc (1.8.1) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rainbow (3.1.1) + rake (13.4.2) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + regexp_parser (2.13.1) + reline (0.7.0) + io-console (~> 0.5) + rexml (3.4.4) + rouge (4.7.0) + rubocop (1.57.2) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.4) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.50.0) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-jekyll (0.14.0) + rubocop (~> 1.57.0) + rubocop-performance (~> 1.2) + rubocop-performance (1.23.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-brs (1.3.3) + adsp (~> 1.0) + ruby-filemagic (0.7.3) + ruby-ll (2.2.0) + ansi + ast + ruby-oembed (0.18.1) + ruby-progressbar (1.13.0) + ruby-vips (2.3.0) + ffi (~> 1.12) + logger + ruby2_keywords (0.0.5) + safe_yaml (1.0.5) + sass-embedded (1.83.4) + google-protobuf (~> 4.29) + rake (>= 13) + sass-embedded (1.83.4-arm64-darwin) + google-protobuf (~> 4.29) + sass-embedded (1.83.4-x86_64-darwin) + google-protobuf (~> 4.29) + sutty-liquid (0.13.3) + fast_blank (~> 1.0) + jekyll (~> 4) + loofah + rails-html-sanitizer (~> 1.6.0) + terminal-table (3.0.2) + unicode-display_width (>= 1.1.1, < 3) + unicode-display_width (2.6.0) + url-privacy (0.1.2) + webrick (1.9.2) + zeitwerk (2.6.18) + +PLATFORMS + arm64-darwin + x86_64-darwin + x86_64-linux-musl + +DEPENDENCIES + bigdecimal (= 3.1.9) + jekyll (~> 4.4.0) + jekyll-activity-pub (~> 0.3.0) + jekyll-brotli + jekyll-data + jekyll-drafts-as-metadata + jekyll-embed-urls + jekyll-gzip + jekyll-hardlinks + jekyll-ignore-layouts + jekyll-images + jekyll-include-cache + jekyll-linked-posts + jekyll-locales + jekyll-logger-tap + jekyll-nokogiri + jekyll-order + jekyll-raw-html-converter + jekyll-relative-urls + jekyll-seo-tag + jekyll-sitemap + prometheus_exporter + pry + rubocop-jekyll + ruby-brs + sass-embedded (~> 1.83.0) + sutty-liquid + +BUNDLED WITH + 2.6.9 diff --git a/docker/dev/setup.sh b/docker/dev/setup.sh new file mode 100755 index 0000000..8f2c33e --- /dev/null +++ b/docker/dev/setup.sh @@ -0,0 +1,42 @@ +#!/bin/sh +set -eu + +ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/../.." && pwd) +cd "$ROOT" + +export BUNDLE_GEMFILE="$ROOT/docker/dev/Gemfile" +export GEMS_SOURCE=https://rubygems.org + +if [ ! -f _bin/pagefind ] || head -c 128 _bin/pagefind | grep -q 'git-lfs.github.com'; then + echo "error: LFS assets are missing. Run 'git lfs pull' on the host." >&2 + exit 1 +fi + +if head -c 128 assets/fonts/inter/v18/UcCm3FwrK3iLTcvnUwAT9nA2.woff2 2>/dev/null | grep -q 'git-lfs.github.com'; then + echo "error: LFS font assets are pointers. Run 'git lfs pull' on the host." >&2 + exit 1 +fi + +echo "==> Installing Ruby gems" +bundle check || bundle install + +echo "==> Installing Node modules" +pnpm install --frozen-lockfile --store-dir=/tmp/pnpm-store + +if [ ! -f privkey.pem ]; then + echo "==> Generating a development ActivityPub key" + openssl genrsa -out privkey.pem 2048 + chmod 600 privkey.pem +fi + +if [ ! -f assets/fonts/forkawesome-webfont.woff2 ]; then + echo "==> Generating the Fork Awesome subset" + ./_bin/subset_fork_awesome.sh || echo "warning: could not generate Fork Awesome subset" >&2 +fi + +# Build before starting the server so Pagefind's output is present when +# Jekyll creates its static-file list. +echo "==> Building the site" +bundle exec jekyll build --config _config.yml,_config.docker.yml + +echo "==> Setup complete"