commit 0efeb5a25ffd4791c29d52df6bb5326f16d6b06a Author: Nathan Price Date: Thu Jan 16 19:27:12 2025 -0500 first commit diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ + diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..601c7f2 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "[nginx]": { + "editor.formatOnSave": false + }, +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..2cd1f03 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,65 @@ +FROM node:alpine AS build + +RUN apk --no-cache add git && \ + git clone https://github.com/jackyzha0/quartz.git && \ + cd quartz && git checkout v4.4.0 && cd .. && \ + mkdir -p /usr/share/nginx/html && \ + mv quartz/* /usr/share/nginx/html && \ + rm -rf /usr/share/nginx/html/docs && \ + cd /usr/share/nginx/html && \ + npm ci && npx quartz build && \ + rm -rf /usr/share/nginx/html/node_modules + +FROM nginx:stable-alpine3.20 +COPY --from=build /usr/share/nginx/html /usr/share/nginx/html +COPY default.conf.template /etc/nginx/templates/default.conf.template + +WORKDIR /usr/share/nginx/html + +RUN apk --no-cache add nodejs npm bash dumb-init git && \ + rm -rf /var/cache/apk/* + +RUN ln -s /usr/share/nginx/html/content / && \ + chown -R nginx:nginx /usr/share/nginx/html && \ + chown -R nginx:nginx /usr/share/nginx/html/content + +ENV NGINX_PORT=80 +ENV BASE_URL="quartz.zhao.xyz" +ENV PAGE_TITLE="Quartz Docker" +ENV ENABLE_SPA="true" +ENV ENABLE_POPOVERS="true" +ENV ANALYTICS_PROVIDER="plausible" +ENV IGNORE_PATTERNS="private,templates" +ENV TYPOGRAPHY_HEADER="Schibsted Grotesk" +ENV TYPOGRAPHY_BODY="Source Sans Pro" +ENV TYPOGRAPHY_CODE="IBM-Plex Mono" +ENV LIGHTMODE_LIGHT="#faf8f8" +ENV LIGHTMODE_LIGHTGRAY="#e5e5e5" +ENV LIGHTMODE_GRAY="#bbbbbb" +ENV LIGHTMODE_DARKGRAY="#4e4e4e" +ENV LIGHTMODE_DARK="#2b2b2b" +ENV LIGHTMODE_SECONDARY="#284b63" +ENV LIGHTMODE_TERTIARY="#84a59d" +ENV LIGHTMODE_HIGHLIGHT="rgba(143,159,169,0.15)" +ENV DARKMODE_LIGHT="#161618" +ENV DARKMODE_LIGHTGRAY="#393639" +ENV DARKMODE_GRAY="#646464" +ENV DARKMODE_DARKGRAY="#4d4d4d" +ENV DARKMODE_DARK="#ebebec" +ENV DARKMODE_SECONDARY="#7b97aa" +ENV DARKMODE_TERTIARY="#84a59d" +ENV DARKMODE_HIGHLIGHT="rgba(143,159,169,0.15)" + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["dumb-init", "--"] + +CMD ["/entrypoint.sh"] + + +LABEL org.opencontainers.image.source="https://code.modernleft.org/gravityfargo/quartz-docker" +LABEL org.opencontainers.image.url="https://quartz.jzhao.xyz/" +LABEL org.opencontainers.image.description="A docker image for Quartz, a static site generator." +LABEL org.opencontainers.image.licenses="MIT" +LABEL org.opencontainers.image.authors="Nathan Price " \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..6d3b33f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Matthew (Nathan) Price + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e6e01e2 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +export DOCKER_BUILDKIT=1 +export COMPOSE_DOCKER_CLI_BUILD=1 +export BUILDKIT_PROGRESS=plain + +TAG ?= dev + +.PHONY: build +build: + docker build --tag code.modernleft.org/gravityfargo/quartz-docker:$(TAG) . + +.PHONY: run +run: + docker compose up + +.PHONY: exec +run: + docker exec -it quartz-docker bash + +.PHONY: push +push: + docker push code.modernleft.org/gravityfargo/quartz-docker:$(TAG) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..400345c --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +## Development + +```bash +# Build a development image +make build +# Build a specific version +make build TAG=v4.4.0 +``` diff --git a/default.conf.template b/default.conf.template new file mode 100644 index 0000000..b94f123 --- /dev/null +++ b/default.conf.template @@ -0,0 +1,11 @@ +server { + listen ${NGINX_PORT}; + server_name ${BASE_URL}; + root /usr/share/nginx/html/public; + index index.html; + error_page 404 /404.html; + + location / { + try_files $uri $uri.html $uri/ =404; + } +} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..17ff3c5 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,39 @@ +services: + quartz-docker: + container_name: quartz-docker + image: quartz-docker:dev + ports: + - 80:8080 + environment: + NGINX_PORT: 8080 + PAGE_TITLE: "Quartz Docker" + ENABLE_SPA: "true" + ENABLE_POPOVERS: "true" + ANALYTICS_PROVIDER: "plausible" + BASE_URL: "localhost" + IGNORE_PATTERNS: "private,templates" + TYPOGRAPHY_HEADER: "Schibsted Grotesk" + TYPOGRAPHY_BODY: "Source Sans Pro" + TYPOGRAPHY_CODE: "IBM-Plex Mono" + + # Light Mode Colors + LIGHTMODE_LIGHT: "#faf8f8" + LIGHTMODE_LIGHTGRAY: "#e5e5e5" + LIGHTMODE_GRAY: "#bbbbbb" + LIGHTMODE_DARKGRAY: "#4e4e4e" + LIGHTMODE_DARK: "#2b2b2b" + LIGHTMODE_SECONDARY: "#284b63" + LIGHTMODE_TERTIARY: "#84a59d" + LIGHTMODE_HIGHLIGHT: "rgba(143,159,169,0.15)" + + # Dark Mode Colors + DARKMODE_LIGHT: "#161618" + DARKMODE_LIGHTGRAY: "#393639" + DARKMODE_GRAY: "#646464" + DARKMODE_DARKGRAY: "#4d4d4d" + DARKMODE_DARK: "#ebebec" + DARKMODE_SECONDARY: "#7b97aa" + DARKMODE_TERTIARY: "#84a59d" + DARKMODE_HIGHLIGHT: "rgba(143,159,169,0.15)" + volumes: + - /home/nathan/Repositories/modernleft-docs:/content diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..9883989 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +CONFIG_FILE="/usr/share/nginx/html/quartz.config.ts" +TEMP_FILE="${CONFIG_FILE}.tmp" + +replace_text() { + local search="$1" + local replace="$2" + # file var with default value + local file="${3:-$CONFIG_FILE}" + + if [[ -z "$search" || -z "$replace" ]]; then + echo "Error: Missing arguments" + return 1 + fi + + # Modify a temporary file instead of the original + sed -e "s|${search}|${replace}|g" "$CONFIG_FILE" >"$TEMP_FILE" && mv "$TEMP_FILE" "$CONFIG_FILE" +} +# Quartz Config +replace_text 'pageTitle: "🪴 Quartz 4.0",' "pageTitle: \"${PAGE_TITLE}\"," +replace_text 'enableSPA: true,' "enableSPA: ${ENABLE_SPA}," +replace_text 'enablePopovers: true,' "enablePopovers: ${ENABLE_POPOVERS}," +replace_text 'provider: "plausible",' "provider: \"${ANALYTICS_PROVIDER}\"," +replace_text 'baseUrl: "quartz.zhao.xyz",' "baseUrl: \"${BASE_URL}\"," +replace_text 'ignorePatterns: ["private", "templates"],' "ignorePatterns: [\"${IGNORE_PATTERNS//,/\", \"}\"]," +replace_text 'header: "Schibsted Grotesk",' "header: \"${TYPOGRAPHY_HEADER}\"," +replace_text 'body: "Source Sans Pro",' "body: \"${TYPOGRAPHY_BODY}\"," +replace_text 'code: "IBM-Plex Mono",' "code: \"${TYPOGRAPHY_CODE}\"," +replace_text 'light: "#faf8f8",' "light: \"${LIGHTMODE_LIGHT}\"," +replace_text 'lightgray: "#e5e5e5",' "lightgray: \"${LIGHTMODE_LIGHTGRAY}\"," +replace_text 'gray: "#bbbbbb",' "gray: \"${LIGHTMODE_GRAY}\"," +replace_text 'darkgray: "#4e4e4e",' "darkgray: \"${LIGHTMODE_DARKGRAY}\"," +replace_text 'dark: "#2b2b2b",' "dark: \"${LIGHTMODE_DARK}\"," +replace_text 'secondary: "#284b63",' "secondary: \"${LIGHTMODE_SECONDARY}\"," +replace_text 'tertiary: "#84a59d",' "tertiary: \"${LIGHTMODE_TERTIARY}\"," +replace_text 'highlight: "rgba(143, 159, 169, 0.15)",' "highlight: \"${LIGHTMODE_HIGHLIGHT}\"," +replace_text 'light: "#161618",' "light: \"${DARKMODE_LIGHT}\"," +replace_text 'lightgray: "#393639",' "lightgray: \"${DARKMODE_LIGHTGRAY}\"," +replace_text 'gray: "#646464",' "gray: \"${DARKMODE_GRAY}\"," +replace_text 'darkgray: "#4d4d4d",' "darkgray: \"${DARKMODE_DARKGRAY}\"," +replace_text 'dark: "#ebebec",' "dark: \"${DARKMODE_DARK}\"," +replace_text 'secondary: "#7b97aa",' "secondary: \"${DARKMODE_SECONDARY}\"," +replace_text 'tertiary: "#84a59d",' "tertiary: \"${DARKMODE_TERTIARY}\"," +replace_text 'highlight: "rgba(143, 159, 169, 0.15)",' "highlight: \"${DARKMODE_HIGHLIGHT}\"," +chown nginx:nginx "$CONFIG_FILE" + +# NGINX script to sub variables in the template +/docker-entrypoint.d/20-envsubst-on-templates.sh + +echo "Starting Quartz..." +echo "Installing dependencies..." +npm i >/dev/null + +echo "Building Quartz..." +npx quartz build + +echo "Starting Nginx..." +exec nginx -g "daemon off;"