mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
fix os.version shim, improve docker image
This commit is contained in:
48
Dockerfile
48
Dockerfile
@@ -1,12 +1,6 @@
|
|||||||
|
# Build shim-loader.js
|
||||||
FROM node:20-slim AS build
|
FROM node:20-slim AS build
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
||||||
ca-certificates \
|
|
||||||
curl \
|
|
||||||
binutils \
|
|
||||||
xz-utils \
|
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
@@ -14,49 +8,37 @@ RUN npm ci --ignore-scripts
|
|||||||
|
|
||||||
COPY build.js ./
|
COPY build.js ./
|
||||||
COPY shims/ ./shims/
|
COPY shims/ ./shims/
|
||||||
COPY scripts/ ./scripts/
|
|
||||||
COPY server/ ./server/
|
|
||||||
|
|
||||||
RUN npm run build:shims
|
RUN npm run build:shims
|
||||||
|
|
||||||
|
# Production image. No Obsidian code included.
|
||||||
ARG OBSIDIAN_VERSION=1.8.9
|
# On first run, the entrypoint downloads and patches Obsidian.
|
||||||
RUN curl -fSL "https://github.com/obsidianmd/obsidian-releases/releases/download/v${OBSIDIAN_VERSION}/obsidian_${OBSIDIAN_VERSION}_amd64.deb" \
|
|
||||||
-o /tmp/obsidian.deb \
|
|
||||||
&& mkdir -p /tmp/obsidian-deb \
|
|
||||||
&& ar x /tmp/obsidian.deb --output=/tmp/obsidian-deb \
|
|
||||||
&& mkdir -p /tmp/obsidian-pkg \
|
|
||||||
&& tar -xf /tmp/obsidian-deb/data.tar.xz -C /tmp/obsidian-pkg \
|
|
||||||
&& rm -rf /tmp/obsidian.deb /tmp/obsidian-deb
|
|
||||||
|
|
||||||
|
|
||||||
RUN npx --yes @electron/asar extract \
|
|
||||||
/tmp/obsidian-pkg/opt/Obsidian/resources/obsidian.asar \
|
|
||||||
/build/obsidian-app \
|
|
||||||
&& rm -rf /tmp/obsidian-pkg
|
|
||||||
|
|
||||||
# Patch index.html
|
|
||||||
RUN node scripts/patch-obsidian.js /build/obsidian-app
|
|
||||||
|
|
||||||
RUN cp dist/shim-loader.js /build/obsidian-app/shim-loader.js
|
|
||||||
|
|
||||||
# Production image
|
|
||||||
FROM node:20-slim
|
FROM node:20-slim
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
|
ca-certificates curl binutils xz-utils \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci --omit=dev --ignore-scripts
|
RUN npm ci --omit=dev --ignore-scripts
|
||||||
|
|
||||||
COPY server/ ./server/
|
COPY server/ ./server/
|
||||||
COPY --from=build /build/obsidian-app ./obsidian-app
|
COPY scripts/ ./scripts/
|
||||||
|
COPY images/ ./images/
|
||||||
|
COPY --from=build /build/dist ./dist
|
||||||
|
|
||||||
|
RUN chmod +x /app/scripts/entrypoint.sh
|
||||||
|
|
||||||
ENV PORT=8080
|
ENV PORT=8080
|
||||||
ENV VAULT_ROOT=/vaults
|
ENV VAULT_ROOT=/vaults
|
||||||
|
ENV OBSIDIAN_VERSION=1.8.9
|
||||||
ENV OBSIDIAN_ASSETS_PATH=/app/obsidian-app
|
ENV OBSIDIAN_ASSETS_PATH=/app/obsidian-app
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
|
|
||||||
VOLUME /vaults
|
VOLUME /vaults
|
||||||
|
VOLUME /app/obsidian-app
|
||||||
|
|
||||||
CMD ["node", "server/index.js"]
|
ENTRYPOINT ["/app/scripts/entrypoint.sh"]
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
services:
|
services:
|
||||||
ignis:
|
ignis:
|
||||||
build:
|
build: .
|
||||||
context: .
|
|
||||||
args:
|
|
||||||
OBSIDIAN_VERSION: "1.8.9"
|
|
||||||
ports:
|
ports:
|
||||||
- "8082:8080"
|
- "8082:8080"
|
||||||
|
environment:
|
||||||
|
- OBSIDIAN_VERSION=1.12.4
|
||||||
volumes:
|
volumes:
|
||||||
- ./vaults:/vaults
|
- ./vaults:/vaults
|
||||||
|
- obsidian-app:/app/obsidian-app
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
obsidian-app:
|
||||||
|
|||||||
BIN
images/favicon.png
Normal file
BIN
images/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
BIN
images/ignis.png
Normal file
BIN
images/ignis.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 59 KiB |
37
scripts/entrypoint.sh
Normal file
37
scripts/entrypoint.sh
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OBSIDIAN_DIR="/app/obsidian-app"
|
||||||
|
OBSIDIAN_VERSION="${OBSIDIAN_VERSION:-1.12.4}"
|
||||||
|
|
||||||
|
if [ ! -f "$OBSIDIAN_DIR/index.html" ]; then
|
||||||
|
echo "[ignis] First run. Downloading Obsidian v${OBSIDIAN_VERSION}..."
|
||||||
|
|
||||||
|
curl -fSL "https://github.com/obsidianmd/obsidian-releases/releases/download/v${OBSIDIAN_VERSION}/obsidian_${OBSIDIAN_VERSION}_amd64.deb" \
|
||||||
|
-o /tmp/obsidian.deb
|
||||||
|
|
||||||
|
echo "[ignis] Extracting .deb..."
|
||||||
|
mkdir -p /tmp/obsidian-deb /tmp/obsidian-pkg
|
||||||
|
ar x /tmp/obsidian.deb --output=/tmp/obsidian-deb
|
||||||
|
tar -xf /tmp/obsidian-deb/data.tar.xz -C /tmp/obsidian-pkg
|
||||||
|
|
||||||
|
echo "[ignis] Unpacking asar..."
|
||||||
|
npx --yes @electron/asar extract \
|
||||||
|
/tmp/obsidian-pkg/opt/Obsidian/resources/obsidian.asar \
|
||||||
|
"$OBSIDIAN_DIR"
|
||||||
|
|
||||||
|
echo "[ignis] Patching..."
|
||||||
|
node /app/scripts/patch-obsidian.js "$OBSIDIAN_DIR"
|
||||||
|
|
||||||
|
cp /app/dist/shim-loader.js "$OBSIDIAN_DIR/shim-loader.js"
|
||||||
|
cp /app/images/favicon.png "$OBSIDIAN_DIR/favicon.png"
|
||||||
|
|
||||||
|
|
||||||
|
rm -rf /tmp/obsidian.deb /tmp/obsidian-deb /tmp/obsidian-pkg
|
||||||
|
|
||||||
|
echo "[ignis] Obsidian v${OBSIDIAN_VERSION} ready."
|
||||||
|
else
|
||||||
|
echo "[ignis] Obsidian already set up."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec node /app/server/index.js
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
// Patches the extracted Obsidian asar for browser use:
|
// Patches the extracted Obsidian asar for browser use:
|
||||||
// 1. Removes Content-Security-Policy meta tag
|
// 1. Removes Content-Security-Policy meta tag
|
||||||
// 2. Injects shim-loader.js script (non-deferred, before all other scripts)
|
// 2. Injects shim-loader.js script (non-deferred, before all other scripts)
|
||||||
|
// 3. Injects favicon link
|
||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
@@ -26,6 +27,12 @@ function patchHtml(filePath) {
|
|||||||
"\n",
|
"\n",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Inject favicon into <head>
|
||||||
|
html = html.replace(
|
||||||
|
"</head>",
|
||||||
|
' <link rel="icon" type="image/png" href="favicon.png">\n</head>',
|
||||||
|
);
|
||||||
|
|
||||||
// Inject shim-loader before the first <script> tag
|
// Inject shim-loader before the first <script> tag
|
||||||
html = html.replace(
|
html = html.replace(
|
||||||
'<script type="text/javascript"',
|
'<script type="text/javascript"',
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ const express = require("express");
|
|||||||
|
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
// POST /api/proxy - forward a request to an external URL (bypasses browser CORS)
|
// POST /api/proxy - forward a request to an external URL (bypasses browser CORS)
|
||||||
// Used by the requestUrl shim for plugin installation, update checks, etc.
|
// Used by the requestUrl shim for plugin installation, update checks, etc.
|
||||||
router.post("/", async (req, res) => {
|
router.post("/", async (req, res) => {
|
||||||
const { url, method, headers, body, binary } = req.body;
|
const { url, method, headers, body, binary } = req.body;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export function createFsSync(metadataCache, contentCache, transport) {
|
|||||||
contentCache.delete(path);
|
contentCache.delete(path);
|
||||||
metadataCache.delete(path);
|
metadataCache.delete(path);
|
||||||
|
|
||||||
// Fire-and-forget - suppress ENOENT (file already gone)
|
// Fire-and-forget. suppress ENOENT (file already gone)
|
||||||
transport.unlink(path).catch((e) => {
|
transport.unlink(path).catch((e) => {
|
||||||
if (e.code !== "ENOENT") {
|
if (e.code !== "ENOENT") {
|
||||||
console.error(
|
console.error(
|
||||||
|
|||||||
@@ -26,9 +26,14 @@ export function request(options, callback) {
|
|||||||
if (callback) {
|
if (callback) {
|
||||||
req.once("response", callback);
|
req.once("response", callback);
|
||||||
}
|
}
|
||||||
// Immediately error - real HTTP requests need fetch or the proxy
|
// Immediately error. real HTTP requests need fetch or the proxy
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
req.emit("error", new Error("http.request is not available in the web version. Use requestUrl() instead."));
|
req.emit(
|
||||||
|
"error",
|
||||||
|
new Error(
|
||||||
|
"http.request is not available in the web version. Use requestUrl() instead.",
|
||||||
|
),
|
||||||
|
);
|
||||||
}, 0);
|
}, 0);
|
||||||
return req;
|
return req;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,4 +46,8 @@ export function endianness() {
|
|||||||
return "LE";
|
return "LE";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function version() {
|
||||||
|
return "v20.0.0";
|
||||||
|
}
|
||||||
|
|
||||||
export const EOL = "\n";
|
export const EOL = "\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user