Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cleanup, passthrough runtime variables #710

Merged
merged 2 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,12 @@ COPY . /my-project/
RUN : \
--mount=type=cache,target=/root/.yarn \
# install production dependencies
&& yarn workspaces focus @flyteconsole/client-app --production \
# move the production dependencies to the /app folder
&& mkdir /app \
&& rm -rf node_modules/@flyteorg \
&& cp -R node_modules /app

RUN : \
--mount=type=cache,target=/root/.yarn \
# install all dependencies so we can build
&& yarn workspaces focus --all --production \
&& yarn build:types \
&& BASE_URL=/console yarn run build:prod \
&& mkdir /app \
&& cp -R ./website/dist/* /app

RUN rm -rf /app/node_modules
RUN rm -f /app/client-stats.json

FROM gcr.io/distroless/nodejs
LABEL org.opencontainers.image.source https://github.com/flyteorg/flyteconsole

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,7 @@
"webpack-cli": "^4.10.0",
"webpack-dev-server": "^4.7.4",
"webpack-merge": "^5.8.0",
"webpack-node-externals": "^3.0.0",
"webpack-stats-plugin": "^1.1.1"
"webpack-node-externals": "^3.0.0"
},
"devDependencies": {
"@babel/core": "~7.16.12",
Expand Down
2 changes: 1 addition & 1 deletion website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"build": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' NODE_ENV=development run -T webpack --config webpack.config.ts --mode=development --progress",
"build:prod": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' NODE_ENV=production run -T webpack --config webpack.config.ts --mode=production --progress",
"start": "NODE_ENV=development run -T webpack serve --config webpack.config.ts --mode=development",
"start:prod": "NODE_ENV=production node -r dotenv/config dist/server.js",
"start:prod": "NODE_ENV=production node dist/server.js",
"lint": "run -T eslint . --ext .js,.jsx,.ts,.tsx",
"format": "run -T prettier --ignore-path .eslintignore --write \"**/*.+(js|jsx|ts|tsx|json)\"",
"fix": "yarn lint --fix && yarn format",
Expand Down
11 changes: 8 additions & 3 deletions website/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ import { applyMiddleware } from './plugins';
import env from '../../env';

const expressStaticGzip = require('express-static-gzip');
const dotenv = require('dotenv');

console.log(env);
// configure runtime env variables
dotenv.config();

const PORT = process.env.PORT || 3000;

const app = express();

// Enable logging for HTTP access
Expand Down Expand Up @@ -45,6 +46,11 @@ const showEntryPointUrl = () => {
env.LOCAL_DEV_HOST || env.ADMIN_API_URL?.replace('https', '')
}:${PORT}${env.BASE_URL}`;

console.log(
chalk.green(`App started with the following config:`),
chalk.white(JSON.stringify(env, null, 2)),
);

// Open a new browser tab if in development
if (env.NODE_ENV === 'development') {
// eslint-disable-next-line global-require
Expand Down Expand Up @@ -77,7 +83,6 @@ if (env.ADMIN_API_USE_SSL === 'https') {
app,
)
.listen(PORT, showEntryPointUrl);
console.log(`Server started with SSL: https://localhost:${PORT}/`);
} else {
server = app.listen(PORT, showEntryPointUrl);
}
Expand Down
2 changes: 0 additions & 2 deletions website/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
WEBPACK_PATHS,
getConfigFile,
getDefinePlugin,
statsWriterPlugin,
resolveOptions,
getModuleOptions,
getShouldLoadReactFromCDN,
Expand Down Expand Up @@ -89,7 +88,6 @@ module.exports = (_env: any, argv: { mode: Mode }) => {
module: getModuleOptions(mode),

plugins: [
statsWriterPlugin,
getDefinePlugin(false),
new NodePolyfillPlugin({
includeAliases: ['http', 'https', 'stream', 'zlib'],
Expand Down
15 changes: 1 addition & 14 deletions website/webpack.utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
} from './env';

const fs = require('fs');
const { StatsWriterPlugin } = require('webpack-stats-plugin');

export type Mode = 'development' | 'production';

Expand Down Expand Up @@ -112,7 +111,7 @@ export const logWebpackStats = (mode: Mode) => {
);
console.log(chalk.blue('Public path:'), chalk.green(publicPath));
console.log(
chalk.yellow('TSconfig file used for build:'),
chalk.blue('TSconfig file used for build:'),
chalk.green(getConfigFile(mode)),
);
};
Expand All @@ -134,18 +133,6 @@ export function absoluteVersion(version: string) {
**************************************************************************************
**************************************************************************************
*/
/** Write client stats to a JSON file for production */
export const statsWriterPlugin = new StatsWriterPlugin({
filename: 'client-stats.json',
fields: [
'chunks',
'publicPath',
'assets',
'assetsByChunkName',
'assetsByChunkId',
],
});

/** Limit server chunks to be only one. No need to split code in server */
export const LimitChunksPlugin = new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11578,7 +11578,6 @@ __metadata:
webpack-dev-server: ^4.7.4
webpack-merge: ^5.8.0
webpack-node-externals: ^3.0.0
webpack-stats-plugin: ^1.1.1
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -22404,13 +22403,6 @@ __metadata:
languageName: node
linkType: hard

"webpack-stats-plugin@npm:^1.1.1":
version: 1.1.1
resolution: "webpack-stats-plugin@npm:1.1.1"
checksum: aa553ccfb9389f2d8a2d04eb6289230bc323edb11b0cbdd676d41617dd790a7f0d0844c46b927a9465139b3edb9da2cc7a2ef664891920c052ef4fa5f2797230
languageName: node
linkType: hard

"webpack-virtual-modules@npm:^0.2.2":
version: 0.2.2
resolution: "webpack-virtual-modules@npm:0.2.2"
Expand Down