Skip to content

Commit

Permalink
Fix standalone executable files. Fixes #469 (#470)
Browse files Browse the repository at this point in the history
* Attempt 1: Include package.json in the final binary

* Bundle native deps alongside; bundle migrations in main bundle file; zip everything up

* Upload the zip to the edge release
  • Loading branch information
chrisbenincasa authored Jun 3, 2024
1 parent 6953e60 commit 330637e
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/edge-binary-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ jobs:
tag_name: edge
prerelease: true
files: |
./server/build/tunarr-${{ matrix.os.target_name }}-x64*
./server/build/tunarr-${{ matrix.os.target_name }}-x64.zip*
108 changes: 104 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 54 additions & 2 deletions server/mikro-orm.base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ import { FillerShow } from './src/dao/entities/FillerShow.js';
import { PlexServerSettings } from './src/dao/entities/PlexServerSettings.js';
import { Program } from './src/dao/entities/Program.js';
import { DATABASE_LOCATION_ENV_VAR } from './src/util/constants.js';
import { Migration20240124115044 } from './src/migrations/Migration20240124115044.js';
import { Migration20240126165808 } from './src/migrations/Migration20240126165808.js';
import { Migration20240221201014 } from './src/migrations/Migration20240221201014.js';
import { Migration20240308184352 } from './src/migrations/Migration20240308184352.js';
import { Migration20240319192121 } from './src/migrations/Migration20240319192121.js';
import { Migration20240404182303 } from './src/migrations/Migration20240404182303.js';
import { Migration20240411104034 } from './src/migrations/Migration20240411104034.js';
import { Migration20240416113447 } from './src/migrations/Migration20240416113447.js';
import { Migration20240423195250 } from './src/migrations/Migration20240423195250.js';
import { Migration20240531155641 } from './src/migrations/Migration20240531155641.js';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
Expand Down Expand Up @@ -43,8 +53,50 @@ export default defineConfig({
forceUndefined: true,
dynamicImportProvider: (id) => import(id),
migrations: {
path: './migrations',
pathTs: './src/migrations',
// Explicitly list migrations for a smoother dev experience
// and because we are bundling these.
migrationsList: [
{
name: 'Initial migration',
class: Migration20240124115044,
},
{
name: 'Add index to filler content',
class: Migration20240126165808,
},
{
name: 'Filler context index fix',
class: Migration20240221201014,
},
{
name: 'Add Plex client identifier column',
class: Migration20240308184352,
},
{
name: 'Add artist and album name fields to Program',
class: Migration20240319192121,
},
{
name: 'Implement program grouping table and hierarchy',
class: Migration20240404182303,
},
{
name: 'Deprecate plex_rating_key field on Program',
class: Migration20240411104034,
},
{
name: 'Add guide_flex_title field',
class: Migration20240416113447,
},
{
name: 'Rename season column to season_number on Program',
class: Migration20240423195250,
},
{
name: 'Add program_external_id table',
class: Migration20240531155641,
},
],
},
extensions: [Migrator],
});
1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"@types/uuid": "^9.0.6",
"@types/yargs": "^17.0.29",
"@yao-pkg/pkg": "^5.11.5",
"archiver": "^7.0.1",
"copyfiles": "^2.2.0",
"del-cli": "^3.0.0",
"dotenv-cli": "^7.4.1",
Expand Down
10 changes: 3 additions & 7 deletions server/scripts/bundle.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import esbuild from 'esbuild';
import { copy } from 'esbuild-plugin-copy';
import esbuildPluginPino from 'esbuild-plugin-pino';
import fg from 'fast-glob';
import fs from 'node:fs';
import { basename, resolve } from 'node:path';
import { basename } from 'node:path';
import { rimraf } from 'rimraf';
import { mikroOrmProdPlugin } from '../esbuild/mikro-orm-prod-plugin.js';
import { nativeNodeModulesPlugin } from '../esbuild/native-node-module.js';
import { nodeProtocolPlugin } from '../esbuild/node-protocol.js';
import esbuildPluginPino from 'esbuild-plugin-pino';
import basicPrettyTransport from '../src/util/logging/basicPrettyTransport.js';

if (fs.existsSync('build')) {
console.log('Deleting old build...');
Expand All @@ -21,14 +20,11 @@ console.log('Copying images...');
fs.cpSync('src/resources/images', 'build/resources/images', {
recursive: true,
});
console.log(
resolve(process.cwd(), './src/util/logging/basicPrettyTransport.ts'),
);

console.log('Bundling app...');
const result = await esbuild.build({
entryPoints: {
bundle: 'src/index.ts',
basicPrettyTransport: 'src/util/logging/basicPrettyTransport.ts',
},
bundle: true,
minify: false,
Expand Down
Loading

0 comments on commit 330637e

Please sign in to comment.