quartz-docker/Dockerfile

45 lines
1.7 KiB
Text
Raw Normal View History

2025-01-17 00:27:12 +00:00
FROM node:alpine AS build
RUN apk --no-cache add git && \
git clone https://code.modernleft.org/gravityfargo/quartz.git && \
cd quartz && git switch json-config && cd .. && \
2025-01-17 00:27:12 +00:00
mkdir -p /usr/share/nginx/html && \
mv quartz/* /usr/share/nginx/html && \
cd /usr/share/nginx/html && \
npm ci && npx quartz build && \
rm -rf /usr/share/nginx/html/node_modules /usr/share/nginx/html/docs
2025-01-17 00:27:12 +00:00
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
COPY config.json /usr/share/nginx/html/default-config.json
2025-01-17 00:27:12 +00:00
WORKDIR /usr/share/nginx/html
RUN apk --no-cache add nodejs npm bash dumb-init git && \
2025-01-17 02:27:03 +00:00
rm -rf /var/cache/apk/* && \
echo "*/5 * * * * cd /usr/share/nginx/html/content && git pull >/dev/null 2>&1 && cd /usr/share/nginx/html && npx quartz build >/dev/null 2>&1" > /etc/crontabs/root
2025-01-17 00:27:12 +00:00
RUN mkdir /config && \
ln -s /usr/share/nginx/html/content / && \
2025-01-17 00:27:12 +00:00
chown -R nginx:nginx /usr/share/nginx/html && \
chown -R nginx:nginx /config
2025-01-17 00:27:12 +00:00
# REQUIRED
ENV NGINX_PORT=80
2025-01-17 02:30:25 +00:00
ENV ENABLE_CRON="false"
2025-01-17 02:27:03 +00:00
ENV BUILD_SCHEDULE="*/5 * * * *"
ENV SERVER_NAME="quartz.zhao.xyz"
ENV QUARTZ_CONFIG_PATH="/config/config.json"
2025-01-17 00:27:12 +00:00
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 <gravityfargo@gmodernleft.org>"