From 3c43b7bba4eae02667ef9f5fa88c19af935a435c Mon Sep 17 00:00:00 2001 From: Phil Eaton Date: Fri, 10 Nov 2023 12:41:53 -0500 Subject: [PATCH] Drop server --- e2e/index.js | 70 ------------ ee/ui/scripts/ui.build | 15 --- server/app.test.js | 33 ------ server/app.ts | 125 --------------------- server/auth.test.js | 3 - server/auth.ts | 129 ---------------------- server/config.test.js | 19 ---- server/config.ts | 91 --------------- server/index.ts | 20 ---- server/log.test.js | 3 - server/log.ts | 9 -- server/migrations/1_init.sql | 14 --- server/release/config.yaml | 19 ---- server/release/datastation-exporter.timer | 10 -- server/release/datastation.service | 19 ---- server/release/install.sh | 16 --- server/rpc.test.js | 40 ------- server/rpc.ts | 50 --------- server/runner.test.js | 3 - server/runner.ts | 15 --- server/scripts/build_image.sh | 6 - server/scripts/release.build | 35 ------ server/scripts/server.build | 18 --- server/scripts/test_release.sh | 64 ----------- server/scripts/test_systemd_dockerfile | 10 -- 25 files changed, 836 deletions(-) delete mode 100644 e2e/index.js delete mode 100644 ee/ui/scripts/ui.build delete mode 100644 server/app.test.js delete mode 100644 server/app.ts delete mode 100644 server/auth.test.js delete mode 100644 server/auth.ts delete mode 100644 server/config.test.js delete mode 100644 server/config.ts delete mode 100644 server/index.ts delete mode 100644 server/log.test.js delete mode 100644 server/log.ts delete mode 100644 server/migrations/1_init.sql delete mode 100644 server/release/config.yaml delete mode 100644 server/release/datastation-exporter.timer delete mode 100644 server/release/datastation.service delete mode 100755 server/release/install.sh delete mode 100644 server/rpc.test.js delete mode 100644 server/rpc.ts delete mode 100644 server/runner.test.js delete mode 100644 server/runner.ts delete mode 100755 server/scripts/build_image.sh delete mode 100644 server/scripts/release.build delete mode 100644 server/scripts/server.build delete mode 100755 server/scripts/test_release.sh delete mode 100644 server/scripts/test_systemd_dockerfile diff --git a/e2e/index.js b/e2e/index.js deleted file mode 100644 index 3bc5d254b..000000000 --- a/e2e/index.js +++ /dev/null @@ -1,70 +0,0 @@ -const webdriver = require('selenium-webdriver'); -const fs = require('fs'); -const assert = require('assert'); -const path = require('path'); -const { spawn } = require('child_process'); - -async function run() { - const chrome = spawn('yarn', ['run', 'chromedriver'], { - shell: process.platform === 'win32', - }); - await new Promise((resolve, reject) => { - try { - chrome.stderr.on('data', (d) => - process.stderr.write('[CHROME] ' + d + '\n') - ); - chrome.stdout.on('data', (data) => { - try { - if (data.includes('ChromeDriver was started successfully.')) { - resolve(); - } - process.stdout.write('[CHROME] ' + data + '\n'); - } catch (e) { - reject(e); - } - }); - } catch (e) { - reject(e); - } - }); - - const applicationPath = { - darwin: 'DataStation Desktop CE.app/Contents/MacOS/DataStation Desktop CE', - win32: 'DataStation Desktop CE.exe', - linux: 'DataStation Desktop CE', - }[process.platform]; - - const directory = path.join( - 'releases', - `DataStation Desktop CE-${process.platform}-${process.arch}` - ); - - const driver = new webdriver.Builder() - // The "9515" is the port opened by chrome driver. - .usingServer('http://localhost:9515') - .withCapabilities({ - 'goog:chromeOptions': { - binary: path.join(process.cwd(), directory, applicationPath), - }, - }) - .forBrowser('chrome') - .build(); - - let reached = false; - try { - await driver.wait(async () => { - const title = await driver.getTitle(); - assert.equal(title, 'DataStation Desktop CE'); - reached = true; - return true; - }, 10_000); - } finally { - await driver.quit(); - process.kill(chrome.pid); // This doesn't do anything on Windows. Need to manually `ps | grep chromedriver` and kill it. TODO: script. - } - - assert.equal(reached, true); - process.exit(0); -} - -run(); diff --git a/ee/ui/scripts/ui.build b/ee/ui/scripts/ui.build deleted file mode 100644 index 0f25f69f8..000000000 --- a/ee/ui/scripts/ui.build +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright 2022 Multiprocess Labs LLC - -mkdir build -# This is overwritten in production builds -setenv_default UI_ESBUILD_ARGS "" -yarn esbuild --target=es2020,chrome90,firefox90,safari13,edge90 ui/index.tsx --loader:.ts=tsx --loader:.js=jsx "--external:fs" --bundle --sourcemap {UI_ESBUILD_ARGS} --outfile=build/ui.js - -setenv_default UI_CONFIG_OVERRIDES "" -prepend {UI_CONFIG_OVERRIDES} build/ui.js - -setenv_default UI_TITLE "DataStation Enterprise Edition" -setenv_default UI_CSP "" -setenv_default UI_ROOT "" -render ../ui/index.html build/index.html -yarn sass ../ui/style.scss ./build/style.css \ No newline at end of file diff --git a/server/app.test.js b/server/app.test.js deleted file mode 100644 index 0d94998ef..000000000 --- a/server/app.test.js +++ /dev/null @@ -1,33 +0,0 @@ -const { Config } = require('./config'); -const { App, init } = require('./app'); - -const basicConfig = new Config(); -basicConfig.auth.sessionSecret = 'a secret test secret'; -// Not great but for now the tests need a working openid server, set up with garbage configuration. -basicConfig.auth.openId = { - realm: 'https://accounts.google.com', - clientId: '12', - clientSecret: '89', -}; -basicConfig.server.tlsKey = ''; -basicConfig.server.tlsCert = ''; - -describe('app.serve', function () { - const server = { listen: jest.fn() }; - let app = new App(basicConfig, () => {}); - app.http.createServer = jest.fn(() => server); - app.https.createServer = jest.fn(() => server); - - beforeAll(async function () { - await app.serve(); - }); - - test('it creates server', () => { - expect(app.http.createServer.mock.calls.length).toBe(1); - expect(app.https.createServer.mock.calls.length).toBe(0); - }); - - test('it listens', () => { - expect(server.listen.mock.calls.length).toBe(1); - }); -}); diff --git a/server/app.ts b/server/app.ts deleted file mode 100644 index ac1b87e84..000000000 --- a/server/app.ts +++ /dev/null @@ -1,125 +0,0 @@ -import cookieParser from 'cookie-parser'; -import express from 'express'; -import fs from 'fs'; -import http from 'http'; -import https from 'https'; -import path from 'path'; -import { CODE_ROOT } from '../desktop/constants'; -import { RPCHandler } from '../desktop/rpc'; -import { initialize } from '../desktop/runner'; -import { Store } from '../desktop/store'; -import { humanSize } from '../shared/text'; -import { registerAuth } from './auth'; -import { Config } from './config'; -import log from './log'; -import { handleRPC } from './rpc'; - -export class App { - config: Config; - express: express.Express; - fs: typeof fs; - http: typeof http; - https: typeof https; - - constructor(config: Config) { - this.express = express(); - this.config = config; - - // So these can be overridden in tests - this.fs = fs; - this.http = http; - this.https = https; - // Done for overrides - } - - static make(config: Config) { - return new App(config); - } - - async serve(handlers: RPCHandler[]) { - this.express.use(cookieParser()); - this.express.use(express.json()); - - this.express.use((req, res, next) => { - const start = new Date(); - res.on('finish', () => { - const end = new Date(); - log.info( - `${res.statusCode} ${req.method} ${req.url} ${humanSize( - +res.getHeader('content-length') || 0 - )} ${end.valueOf() - start.valueOf()}ms` - ); - }); - next(); - }); - const auth = await registerAuth('/a/auth', this, this.config); - - this.express.post('/a/rpc', auth.requireAuth, (req, rsp) => - handleRPC(req, rsp, handlers) - ); - - // Serve static files - // Mask with nginx in production - const staticFiles = ['index.html', 'style.css', 'ui.js', 'ui.js.map']; - staticFiles.map((f) => { - if (f === 'index.html') { - this.express.get('/', (req, rsp) => - rsp.sendFile(path.join(CODE_ROOT, '/build/index.html')) - ); - return; - } - - this.express.get('/' + f, (req, rsp) => - rsp.sendFile(path.join(CODE_ROOT, 'build', f)) - ); - }); - - // Must go last? - this.express.get('*', (req: express.Request, rsp: express.Response) => { - rsp.sendStatus(404); - }); - - const server = this.config.server.tlsKey - ? this.https.createServer( - { - key: this.fs.readFileSync(this.config.server.tlsKey), - cert: this.fs.readFileSync(this.config.server.tlsCert), - }, - this.express - ) - : this.http.createServer(this.express); - const location = this.config.server.address + ':' + this.config.server.port; - server.listen( - { - port: this.config.server.port, - host: this.config.server.address, - }, - () => { - const protocol = this.config.server.tlsKey ? 'https' : 'http'; - log.info( - `Server running on ${protocol}://${location}, publicly accessible at ${this.config.server.publicUrl}` - ); - } - ); - - process.on('SIGINT', async function () { - log.info('Gracefully shutting down from SIGINT'); - server.close(() => process.exit(1)); - }); - } -} - -export async function init(app: App, withSubprocess = true) { - const store = new Store(); - const { handlers } = initialize({ - subprocess: withSubprocess - ? { - node: path.join(__dirname, 'server_runner.js'), - go: path.join(CODE_ROOT, 'build', 'go_server_runner'), - } - : undefined, - additionalHandlers: store.getHandlers(), - }); - - return { handlers }; -} diff --git a/server/auth.test.js b/server/auth.test.js deleted file mode 100644 index 8f748d30c..000000000 --- a/server/auth.test.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./auth'); - -test('stub', () => {}); diff --git a/server/auth.ts b/server/auth.ts deleted file mode 100644 index 370e5cd29..000000000 --- a/server/auth.ts +++ /dev/null @@ -1,129 +0,0 @@ -import express from 'express'; -import session from 'express-session'; -import { - Issuer, - Client as OpenIDClient, - TokenSet, - generators, -} from 'openid-client'; -import passport from 'passport'; -import { App } from './app'; -import { Config } from './config'; -import log from './log'; - -export interface AuthRequestSession extends express.Request { - session: session.Session & - Partial & { - tokenSet: TokenSet; - code: string; - redirect: string; - }; -} - -export function authenticated(req: AuthRequestSession) { - return ( - req.session.tokenSet && - new Date(req.session.tokenSet.expires_at * 1000) >= new Date() - ); -} - -export class Auth { - config: Config; - openIdClient?: OpenIDClient; - path: string; - - constructor(config: Config, path: string) { - this.config = config; - this.path = path; - } - - async init() { - if (this.config.auth.openId) { - const issuer = await Issuer.discover(this.config.auth.openId.realm); - const callbackUrl = `${this.config.server.publicUrl}${this.path}/callback`; - this.openIdClient = new issuer.Client({ - client_id: this.config.auth.openId.clientId, - client_secret: this.config.auth.openId.clientSecret, - redirect_uris: [callbackUrl], - response_types: ['code'], - }); - } else { - log.error('Auth is disabled.'); - } - } - - requireAuth = ( - req: AuthRequestSession, - rsp: express.Response, - next: () => void - ) => { - if (!this.openIdClient) { - return next(); - } - - if (!authenticated(req)) { - req.session.redirect = ('/?projectId=' + req.query.projectId) as string; - rsp.status(401).json({}); - return; - } - - return next(); - }; - - doAuth = async (req: AuthRequestSession, rsp: express.Response) => { - if (this.openIdClient) { - const codeVerifier = generators.codeVerifier(); - req.session.code = codeVerifier; - const codeChallenge = generators.codeChallenge(codeVerifier); - - const externalRedirect = this.openIdClient.authorizationUrl({ - scope: 'openid profile email', - code_challenge: codeChallenge, - code_challenge_method: 'S256', - }); - rsp.redirect(externalRedirect); - return; - } - }; - - authCallback = async (req: AuthRequestSession, rsp: express.Response) => { - if (this.openIdClient) { - const params = this.openIdClient.callbackParams(req); - const tokenSet = await this.openIdClient.callback( - this.openIdClient.metadata.redirect_uris[0], - params, - { - code_verifier: req.session.code, - } - ); - req.session.tokenSet = tokenSet; - rsp.redirect(req.session.redirect); - return; - } - - throw new Error('No auth scheme'); - }; -} - -export async function registerAuth( - path: string, - app: App, - config: Config -): Promise { - app.express.use( - session({ - secret: config.auth.sessionSecret, - resave: true, - saveUninitialized: true, - }) - ); - app.express.use(passport.initialize()); - app.express.use(passport.session()); - - const auth = new Auth(config, path); - await auth.init(); - - app.express.get(path + '/', auth.doAuth); - app.express.get(path + '/callback', auth.authCallback); - return auth; -} diff --git a/server/config.test.js b/server/config.test.js deleted file mode 100644 index df2e4b9c9..000000000 --- a/server/config.test.js +++ /dev/null @@ -1,19 +0,0 @@ -const { Config, mergeFromEnv } = require('./config'); - -test('mergeFromEnv', function testMergeFromEnv() { - const c = new Config(); - expect(c.database.address).toBe('localhost:5432'); - - mergeFromEnv(c, { - DATASTATION_DATABASE_ADDRESS: 'pg.domain.com', - }); - - expect(c.database.address).toBe('pg.domain.com'); - - mergeFromEnv(c, { - DATASTATION_SERVER_ADDRESS: '0.0.0.0:8080', - }); - - expect(c.database.address).toBe('pg.domain.com'); - expect(c.server.address).toBe('0.0.0.0:8080'); -}); diff --git a/server/config.ts b/server/config.ts deleted file mode 100644 index 93965e7ed..000000000 --- a/server/config.ts +++ /dev/null @@ -1,91 +0,0 @@ -import fs from 'fs'; -import yaml from 'js-yaml'; -import { mergeDeep, setPath, validate } from '../shared/object'; -import log from './log'; - -const CONFIG_PATH = '/etc/datastation/config.yaml'; - -export class Config { - auth: { - sessionSecret: string; - openId?: { - realm: string; - clientId: string; - clientSecret: string; - }; - }; - - server: { - port: number; - address: string; - publicUrl: string; - tlsKey?: string; - tlsCert?: string; - }; - - database: { - address: string; - username: string; - password: string; - database: string; - }; - - constructor() { - this.auth = { - sessionSecret: 'datastation', - }; - this.server = { - port: 8080, - address: 'localhost', - publicUrl: 'http://localhost:8080', - }; - - this.database = { - address: 'localhost:5432', - database: 'datastation', - username: 'datastation', - password: 'datastation', - }; - } -} - -export function mergeFromEnv(cfg: Config, env: Record) { - const keys: [[Array, any]] = [[[], cfg]]; - while (keys.length) { - const [path, top] = keys.pop(); - if (top !== null && typeof top === 'object') { - for (const [key, value] of Object.entries(top)) { - keys.push([[...path, key], value]); - } - } - - const envvar = 'DATASTATION_' + path.join('_').toUpperCase(); - if (env[envvar]) { - setPath(cfg, path.join('.'), env[envvar]); - } - } -} - -export function readConfig(): Config { - const raw = fs.readFileSync(CONFIG_PATH); - const rawYaml = yaml.load(raw.toString()); - - const cfg = mergeDeep(new Config(), rawYaml); - - mergeFromEnv(cfg, process.env); - - const requiredFields = [ - 'auth.sessionSecret', - 'auth.openId?.realm', - 'auth.openId?.clientId', - 'auth.openId?.clientSecret', - 'server.publicUrl', - 'database.address', - 'database.database', - ]; - validate(cfg, requiredFields, (badKey) => { - log.fatal(`'${badKey}' is a required field in config.yaml`); - }); - - return cfg; -} diff --git a/server/index.ts b/server/index.ts deleted file mode 100644 index 70033726e..000000000 --- a/server/index.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { APP_NAME, DEBUG, VERSION } from '../shared/constants'; -import { App, init } from './app'; -import { readConfig } from './config'; -import log from './log'; - -process.on('unhandledRejection', (e) => { - log.error(e); -}); -process.on('uncaughtException', (e) => { - log.error(e); -}); -log.info(APP_NAME, VERSION, DEBUG ? 'DEBUG' : ''); - -async function main() { - const app = App.make(readConfig()); - const { handlers } = await init(app); - await app.serve(handlers); -} - -main(); diff --git a/server/log.test.js b/server/log.test.js deleted file mode 100644 index 989a2ee7f..000000000 --- a/server/log.test.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./log'); - -test('stub', () => {}); diff --git a/server/log.ts b/server/log.ts deleted file mode 100644 index 4db988ec6..000000000 --- a/server/log.ts +++ /dev/null @@ -1,9 +0,0 @@ -import log from '../shared/log'; - -export default { - ...log, - fatal: (...args: any[]) => { - log.error(...args); - process.exit(1); - }, -}; diff --git a/server/migrations/1_init.sql b/server/migrations/1_init.sql deleted file mode 100644 index 1dc4244eb..000000000 --- a/server/migrations/1_init.sql +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN; - -CREATE TABLE projects ( - project_name TEXT PRIMARY KEY, - project_value JSONB NOT NULL, - project_created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() -); - -CREATE TABLE migrations ( - migration_name TEXT PRIMARY KEY, - migration_created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW() -); - -COMMIT; diff --git a/server/release/config.yaml b/server/release/config.yaml deleted file mode 100644 index 215d218e0..000000000 --- a/server/release/config.yaml +++ /dev/null @@ -1,19 +0,0 @@ -auth: - sessionSecret: "some good long random string" # Any strong random string for signing sessions - openId: - realm: https://accounts.google.com # Or some other realm - clientId: "my id" - clientSecret: "my secret" - -server: - port: 443 - address: localhost - publicUrl: https://datastation.mydomain.com # The address users will enter into the browser to use the app - tlsKey: /home/server/certs/datastation.key.pem # Can be left blank and set at the reverse-proxy level if desired - tlsCert: /home/server/certs/datastation.cert.pem - -database: - address: localhost # Address of your PostgreSQL instance - username: datastation # Should be a dedicated PostgreSQL user for DataStation - password: "some good password" - database: datastation # Should be a dedicated database within PostgreSQL for DataStation \ No newline at end of file diff --git a/server/release/datastation-exporter.timer b/server/release/datastation-exporter.timer deleted file mode 100644 index 41d69a91d..000000000 --- a/server/release/datastation-exporter.timer +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Run DataStation exporter daily - -[Timer] -OnCalendar=daily -Persistent=true -ExecStart=node /usr/share/datastation/exporter.js - -[Install] -WantedBy=timers.target \ No newline at end of file diff --git a/server/release/datastation.service b/server/release/datastation.service deleted file mode 100644 index 7964d4fc0..000000000 --- a/server/release/datastation.service +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=DataStation -After=network.target -StartLimitIntervalSec=0 - -[Service] -Type=simple -Restart=always -RestartSec=1 -User=datastation -ExecStartPre= -WorkingDirectory=/usr/share/datastation -ExecStart=node /usr/share/datastation/build/server.js -ExecStartPost= -ExecStop= -ExecReload= - -[Install] -WantedBy=multi-user.target \ No newline at end of file diff --git a/server/release/install.sh b/server/release/install.sh deleted file mode 100755 index edbb59549..000000000 --- a/server/release/install.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -ex - -ROOT_DIR="$(readlink -f $(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)/..)" - -sudo mkdir -p /etc/datastation /usr/share /etc/systemd/system /home/datastation -sudo cp $ROOT_DIR/release/config.yaml /etc/datastation/ -sudo cp $ROOT_DIR/release/datastation.service /etc/systemd/system/ -# sudo cp $ROOT_DIR/release/datastation-exporter.timer /etc/systemd/system/ -sudo mv $ROOT_DIR /usr/share/datastation - -sudo id -u datastation >/dev/null 2>&1 || sudo useradd -r -s /bin/false datastation -sudo chown -R datastation:datastation /etc/datastation /usr/share/datastation /home/datastation - -sudo systemctl enable datastation diff --git a/server/rpc.test.js b/server/rpc.test.js deleted file mode 100644 index 243deb5f5..000000000 --- a/server/rpc.test.js +++ /dev/null @@ -1,40 +0,0 @@ -const { handleRPC } = require('./rpc'); - -test('dispatching works', async () => { - let done = false; - - const req = { - query: { - resource: 'test', - projectId: 'my project', - body: { abody: 'a thing' }, - }, - body: {}, - }; - - const rsp = { - json(msg) { - expect(msg).toStrictEqual({ aresponse: true }); - done = true; - }, - }; - - const handlers = [ - { - resource: 'test', - handler: (projectId, body, dispatch, external) => { - // TODO: test internal dispatch - - expect(projectId).toBe('my project'); - expect(body).toStrictEqual({ abody: 'a thing' }); - expect(typeof dispatch).toStrictEqual('function'); - expect(external).toStrictEqual(true); - return { aresponse: true }; - }, - }, - ]; - - await handleRPC(req, rsp, handlers); - - expect(done).toBe(true); -}); diff --git a/server/rpc.ts b/server/rpc.ts deleted file mode 100644 index 5306512bc..000000000 --- a/server/rpc.ts +++ /dev/null @@ -1,50 +0,0 @@ -import express from 'express'; -import { DispatchPayload, RPCHandler } from '../desktop/rpc'; -import log from '../shared/log'; - -export function makeDispatch( - handlers: RPCHandler[] -) { - return async function dispatch( - payload: DispatchPayload, - external = false - ) { - const handler = handlers.filter((h) => h.resource === payload.resource)[0]; - if (!handler) { - throw new Error(`No RPC handler for resource: ${payload.resource}`); - } - - return await handler.handler( - payload.projectId, - payload.body, - dispatch, - external - ); - }; -} - -export async function handleRPC( - req: express.Request, - rsp: express.Response, - rpcHandlers: RPCHandler[] -) { - const payload = { - ...req.query, - ...req.body, - }; - - const dispatch = makeDispatch(rpcHandlers); - - try { - const rpcResponse = await dispatch(payload, true); - rsp.json(rpcResponse || { message: 'ok' }); - } catch (e) { - log.error(e); - rsp.status(400).json({ - ...e, - // Needs to get passed explicitly or name comes out as Error after rpc - message: e.message, - name: e.name, - }); - } -} diff --git a/server/runner.test.js b/server/runner.test.js deleted file mode 100644 index 305396ebb..000000000 --- a/server/runner.test.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./runner'); - -test('stub', () => {}); diff --git a/server/runner.ts b/server/runner.ts deleted file mode 100644 index 038579c95..000000000 --- a/server/runner.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { main as baseMain } from '../desktop/runner'; -import { APP_NAME, DEBUG, VERSION } from '../shared/constants'; -import log from '../shared/log'; -import { App, init } from './app'; -import { readConfig } from './config'; - -export async function main(app: App) { - const { handlers } = await init(app, false); - log.info(APP_NAME + ' Panel Runner', VERSION, DEBUG ? 'DEBUG' : ''); - await baseMain(handlers); -} - -if ((process.argv[1] || '').includes('server_runner.js')) { - main(App.make(readConfig())); -} diff --git a/server/scripts/build_image.sh b/server/scripts/build_image.sh deleted file mode 100755 index 5f1c69d15..000000000 --- a/server/scripts/build_image.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -set -eu - -image=$(docker build . --quiet -f Dockerfile.build -t datastation-builder) -docker run -v $(pwd):/datastation "$image" yarn build-server diff --git a/server/scripts/release.build b/server/scripts/release.build deleted file mode 100644 index 5bf5a2c75..000000000 --- a/server/scripts/release.build +++ /dev/null @@ -1,35 +0,0 @@ -rm -rf build -yarn -setenv UI_ESBUILD_ARGS "--minify" - -yarn build-server -prepend "window.DS_CONFIG_MODE='server';" build/ui.js -prepend "window.DS_CONFIG_VERSION='{arg0}';" build/ui.js -prepend "window.DS_CONFIG_VERSION='{arg0}';" build/server_runner.js -prepend "global.DS_CONFIG_VERSION='{arg0}';" build/server.js - -# Need to have a directory with a build directory and a node_modules directory -rm -rf datastation -mkdir datastation -mkdir datastation/node_modules -mv build datastation/ - -# Bring in sampledata -cp -r sampledata datastation/sampledata - -# Bring in node_modules -prepend "{{}}" datastation/package.json -cd datastation && yarn add asar electron better-sqlite3 -rm datastation/yarn.lock -rm datastation/package.json -# Only need stubs not full chrome install -rm -rf datastation/node_modules/electron/dist - -cp node_modules/better-sqlite3/build/Release/better_sqlite3.node datastation/build/ -# Copy in install script and default configs -cp -r server/release datastation/release - -mkdir releases -tar -zcvf releases/datastation-server-{arch}-{arg0}.tar.gz datastation - -rm -rf datastation \ No newline at end of file diff --git a/server/scripts/server.build b/server/scripts/server.build deleted file mode 100644 index e0284ce16..000000000 --- a/server/scripts/server.build +++ /dev/null @@ -1,18 +0,0 @@ -setenv UI_CONFIG_OVERRIDES "window.DS_CONFIG_MODE = 'server'; window.DS_CONFIG_UI_TITLE = 'DataStation Server CE';" - -setenv UI_TITLE "DataStation Server CE" -setenv UI_ROOT "/" -yarn build-ui - -cd runner && go build -trimpath -buildmode=pie -mod=readonly -modcacherw -ldflags="-s -w" -o ../build/go_server_runner{required_ext} ./cmd/main.go - -yarn esbuild server/runner.ts --sourcemap --platform=node --bundle --target=node10.4 --external:sqlite3 --external:asar --external:react-native-fs --external:react-native-fetch-blob --external:cpu-features --external:electron --outfile=build/server_runner.js -yarn esbuild server/index.ts --sourcemap --platform=node --bundle --external:sqlite3 --external:react-native-fs --external:asar --external:react-native-fetch-blob --external:cpu-features --external:electron --outfile=build/server.js - -prepend "global.DS_UI_TITLE='DataStation Server CE';" build/server.js - -rm -rf build/migrations -cp -r desktop/migrations build/ - -setenv_default SERVER_CONFIG_OVERRIDES "" -prepend {SERVER_CONFIG_OVERRIDES} build/server.js diff --git a/server/scripts/test_release.sh b/server/scripts/test_release.sh deleted file mode 100755 index 317d13aba..000000000 --- a/server/scripts/test_release.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -set -e - -function docker() { - podman "$@" -} - -cp ./releases/$1 ./releases/datastation-docker-release-test.tar.gz -docker build . -q -f ./server/scripts/test_systemd_dockerfile -t datastation-server-test -cid=$(docker run -d datastation-server-test:latest) - -debug() { - rv=$? - if ! [[ "$rv" == "0" ]]; then - docker ps -a - docker logs $cid - docker rm -f $cid || echo "Container already exited." - fi - exit $rv -} -trap "debug" exit - -function c_run() { - docker exec $cid bash -c "$1" -} - -# TODO: test out systemd settings eventually -# # Copy in zip file -# docker cp ./releases/$1 $cid:/ -# -# c_run "tar xvzf /$1" -# c_run "/datastation/release/install.sh" -# c_run "truncate --size 0 /etc/datastation/config.yaml" -# c_run "systemctl restart datastation" - -# Wait for server to start -sleep 10 - -result="$(c_run 'curl localhost:8080')" - -expected='DataStation Server CE - - - - - - - -
-
Loading...
-
- -' - -if ! diff -u -wB <(echo "$expected") <(echo "$result"); then - echo "Unexpected response body:" - echo "$result" - exit 1 -fi - - -echo "Looks ok!" -exit 0 diff --git a/server/scripts/test_systemd_dockerfile b/server/scripts/test_systemd_dockerfile deleted file mode 100644 index b11670d29..000000000 --- a/server/scripts/test_systemd_dockerfile +++ /dev/null @@ -1,10 +0,0 @@ -FROM fedora - -RUN dnf install -y systemd tar -RUN dnf module reset nodejs && dnf module install -y nodejs:16 - -COPY /releases/datastation-docker-release-test.tar.gz /datastation-server.tar.gz -RUN tar xvzf /datastation-server.tar.gz -RUN mkdir -p /etc/datastation && touch /etc/datastation/config.yaml - -CMD ["node", "/datastation/build/server.js"] \ No newline at end of file