mirror of
https://github.com/bookorbit/bookorbit.git
synced 2026-11-03 00:11:37 -06:00
revert: undo kepubify Docker build-time install
This commit is contained in:
+1
-12
@@ -40,19 +40,8 @@ RUN mkdir -p /deploy/migrations && cp -r /app/server/src/db/migrations/. /deploy
|
||||
FROM ${NODE_IMAGE} AS runtime
|
||||
WORKDIR /app
|
||||
|
||||
ARG TARGETARCH
|
||||
RUN apk upgrade --no-cache && \
|
||||
apk add --no-cache poppler-utils su-exec curl && \
|
||||
case "$TARGETARCH" in \
|
||||
amd64) KEPUBIFY_BIN="kepubify-linux-64bit" ;; \
|
||||
arm64) KEPUBIFY_BIN="kepubify-linux-arm64" ;; \
|
||||
arm) KEPUBIFY_BIN="kepubify-linux-arm" ;; \
|
||||
386) KEPUBIFY_BIN="kepubify-linux-32bit" ;; \
|
||||
esac && \
|
||||
curl -fsSL "https://github.com/neonsolstice/projectx-tools/raw/main/kepubify/${KEPUBIFY_BIN}" \
|
||||
-o /usr/local/bin/kepubify && \
|
||||
chmod +x /usr/local/bin/kepubify && \
|
||||
apk del curl && \
|
||||
apk add --no-cache poppler-utils su-exec && \
|
||||
rm -rf /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx
|
||||
|
||||
ENV NODE_ENV=production
|
||||
|
||||
@@ -48,19 +48,8 @@ describe('KepubifyBinaryService', () => {
|
||||
expect(() => (service as any).detectBinaryName()).toThrow('Unsupported platform');
|
||||
});
|
||||
|
||||
it('returns system binary path when kepubify is already installed', async () => {
|
||||
it('caches computed binary path after first resolution', async () => {
|
||||
const service = new KepubifyBinaryService(config as never);
|
||||
statMock.mockResolvedValue({} as never);
|
||||
|
||||
await expect(service.getBinaryPath()).resolves.toBe('/usr/local/bin/kepubify');
|
||||
await expect(service.getBinaryPath()).resolves.toBe('/usr/local/bin/kepubify');
|
||||
|
||||
expect(statMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('caches computed binary path after first resolution when system binary absent', async () => {
|
||||
const service = new KepubifyBinaryService(config as never);
|
||||
statMock.mockRejectedValue(new Error('missing'));
|
||||
const detectSpy = vi.spyOn(service as any, 'detectBinaryName').mockReturnValue('kepubify-linux-64bit');
|
||||
const ensureSpy = vi.spyOn(service as any, 'ensureBinary').mockResolvedValue(undefined);
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import { Injectable, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
const KEPUBIFY_BASE_URL = 'https://github.com/neonsolstice/projectx-tools/raw/main/kepubify/';
|
||||
const SYSTEM_BINARY_PATH = '/usr/local/bin/kepubify';
|
||||
|
||||
@Injectable()
|
||||
export class KepubifyBinaryService {
|
||||
@@ -19,12 +18,6 @@ export class KepubifyBinaryService {
|
||||
|
||||
async getBinaryPath(): Promise<string> {
|
||||
if (this.cachedBinaryPath) return this.cachedBinaryPath;
|
||||
|
||||
if (await this.exists(SYSTEM_BINARY_PATH)) {
|
||||
this.cachedBinaryPath = SYSTEM_BINARY_PATH;
|
||||
return SYSTEM_BINARY_PATH;
|
||||
}
|
||||
|
||||
const binaryName = this.detectBinaryName();
|
||||
const toolsDir = join(this.appDataPath, '.tools', 'kepubify');
|
||||
const binaryPath = join(toolsDir, binaryName);
|
||||
@@ -33,15 +26,6 @@ export class KepubifyBinaryService {
|
||||
return binaryPath;
|
||||
}
|
||||
|
||||
private async exists(path: string): Promise<boolean> {
|
||||
try {
|
||||
await stat(path);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private detectBinaryName(): string {
|
||||
const platform = process.platform;
|
||||
const arch = process.arch;
|
||||
|
||||
Reference in New Issue
Block a user