modified build process to clone the quartz repo to /quartz; this is copied into the build container, any files Ive customized are overlayed and then the site is built

This commit is contained in:
wes
2025-05-29 12:33:58 -04:00
parent aa6719663a
commit 0563f646b2
5 changed files with 124 additions and 7395 deletions
+48 -23
View File
@@ -1,43 +1,68 @@
# Dockerfile
# Stage 1: Build the Quartz site
FROM node:lts-slim AS builder
WORKDIR /app
# Create a non-root user to own files and run npm commands
USER node
WORKDIR /home/node/app
# Copy package.json and package-lock.json (or yarn.lock)
COPY package*.json ./
# Copy the locally cloned Quartz source code from the build context
# This 'quartz_framework_source' dir is expected to be in the build context root,
# prepared by the update_quartz_docker.sh script.
COPY --chown=node:node quartz/ .
# Now /home/node/app contains the full cloned Quartz repo structure,
# including its package.json, its quartz/ directory with bootstrap-cli.mjs, etc.
# Install dependencies
RUN npm i
# Install dependencies based on the cloned Quartz source's package.json
RUN npm ci
# This will also make ./node_modules/.bin/quartz available, pointing to ./quartz/bootstrap-cli.mjs
# Copy the rest of the Quartz project files
COPY . .
# Now, copy your specific custom configuration files and the prepared content
# from the root of your deployment repo (the build context's root)
# into the current WORKDIR (/home/node/app), overwriting any placeholders
# from the cloned Quartz source if they share the same names/paths.
COPY --chown=node:node quartz.config.ts ./quartz.config.ts
COPY --chown=node:node quartz.layout.ts ./quartz.layout.ts
# If you have other custom files/dirs at the root of your deployment repo that Quartz needs:
# e.g., custom assets not part of Obsidian content, or custom components to overlay
# COPY --chown=node:node assets/ ./assets/
# COPY --chown=node:node components/ ./components/
# Build the Quartz site (adjust if your build command is different)
# This usually outputs to a 'public' directory
# Copy the Obsidian content prepared by the host script into ./content
COPY --chown=node:node content/ ./content/
# Now run the build command.
# `npx quartz build` should work because:
# 1. `npm ci` (based on the framework's package.json) made node_modules/.bin/quartz available,
# pointing to the local ./quartz/bootstrap-cli.mjs.
# 2. It will use your custom quartz.config.ts, quartz.layout.ts, and ./content.
RUN npx quartz build
# Output is expected in /home/node/app/public
# ---- START DEBUG ----
RUN echo "Listing contents of /app/public after build:" && ls -lA /app/public
RUN echo "Checking for /app/public/index.html:" && \
if [ -f /app/public/index.html ]; then \
echo "index.html found. First few lines:"; \
head -n 10 /app/public/index.html; \
else \
echo "index.html NOT FOUND in /app/public!"; \
fi
# ---- START DEBUG (Optional) ----
# USER root # If you need root to ls everything for debug
# RUN echo "Listing contents of /home/node/app after all copies:" && ls -lA /home/node/app
# RUN echo "Listing contents of /home/node/app/content:" && ls -lA /home/node/app/content
# RUN echo "Listing contents of /home/node/app/public after build:" && ls -lA /home/node/app/public
# RUN echo "Checking for /home/node/app/public/index.html:" && \
# if [ -f /home/node/app/public/index.html ]; then \
# echo "index.html found. First few lines:"; \
# head -n 10 /home/node/app/public/index.html; \
# else \
# echo "index.html NOT FOUND in /home/node/app/public!"; \
# fi
# USER node # Switch back if you changed it
# ---- END DEBUG ----
# Stage 2: Serve the static files with NGINX
FROM nginx:alpine
# Remove default NGINX configuration
RUN rm /etc/nginx/conf.d/default.conf
# Copy custom NGINX configuration from your project
COPY custom_nginx.conf /etc/nginx/conf.d/default.conf
# Copy only the built static files from the 'builder' stage's 'public' folder
COPY --from=builder /app/public /usr/share/nginx/html
# Adjust source path for public files from the builder stage
COPY --from=builder /home/node/app/public /usr/share/nginx/html
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]