diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index fdb57fbc5..5ade98b91 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -19,6 +19,8 @@ on: - server/** - index.js - package.json + - tsconfig.server.json + - Dockerfile jobs: build: diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index f0c40a58d..beadc7f28 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -12,6 +12,7 @@ on: - test/** - index.js - package.json + - tsconfig.server.json jobs: build: diff --git a/Dockerfile b/Dockerfile index 3f53713b2..14005f25c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,6 @@ RUN apk add --no-cache --update \ WORKDIR /server COPY index.js package* tsconfig.server.json /server -COPY /scripts /server/scripts COPY /server /server/server RUN case "$TARGETPLATFORM" in \ @@ -39,7 +38,7 @@ RUN case "$TARGETPLATFORM" in \ unzip /tmp/library.zip -d $NUSQLITE3_DIR && \ rm /tmp/library.zip -RUN npm ci --include=dev && npm run build:server && npm prune --omit=dev && rm -rf dist-server/test +RUN npm ci --include=dev && npm run build:server && npm prune --omit=dev ### STAGE 2: Create minimal runtime image ### FROM node:20-alpine diff --git a/scripts/buildServer.js b/scripts/buildServer.js deleted file mode 100644 index a8213c4a3..000000000 --- a/scripts/buildServer.js +++ /dev/null @@ -1,46 +0,0 @@ -const fs = require('fs') -const path = require('path') -const { spawnSync } = require('child_process') - -const projectRoot = path.resolve(__dirname, '..') -const outputDirectory = path.join(projectRoot, 'dist-server') - -fs.rmSync(outputDirectory, { recursive: true, force: true }) -fs.mkdirSync(outputDirectory, { recursive: true }) -fs.copyFileSync(path.join(projectRoot, 'package.json'), path.join(outputDirectory, 'package.json')) -fs.copyFileSync(path.join(projectRoot, 'index.js'), path.join(outputDirectory, 'index.js')) - -const devConfigPath = path.join(projectRoot, 'dev.js') -if (fs.existsSync(devConfigPath)) { - fs.copyFileSync(devConfigPath, path.join(outputDirectory, 'dev.js')) -} - -fs.cpSync(path.join(projectRoot, 'server'), path.join(outputDirectory, 'server'), { - recursive: true, - force: true -}) - -const testDirectory = path.join(projectRoot, 'test') -if (fs.existsSync(testDirectory)) { - fs.cpSync(testDirectory, path.join(outputDirectory, 'test'), { - recursive: true, - force: true - }) -} - -function hasTypeScriptSource(directory) { - for (const entry of fs.readdirSync(directory, { withFileTypes: true })) { - const entryPath = path.join(directory, entry.name) - if (entry.isDirectory() && hasTypeScriptSource(entryPath)) return true - if (entry.isFile() && entry.name.endsWith('.ts')) return true - } - return false -} - -if (hasTypeScriptSource(path.join(projectRoot, 'server'))) { - const result = spawnSync(process.execPath, [require.resolve('typescript/bin/tsc'), '--project', 'tsconfig.server.json'], { - cwd: projectRoot, - stdio: 'inherit' - }) - process.exit(result.status || 0) -}