- swaps out `django-push-notifications` for [`fcm-django`](https://github.com/grafana/fcm-django). Again.. this is a fork of the parent repo for exactly the same reason.. the migrations point to `auth_user` without letting us use our own user model, this has been patched in the `grafana` fork. The reason why we are using `fcm-django` vs `django-push-notifications` is that the latter does not support the new FCM API, only the "legacy" API. The legacy FCM API does not support certain push notification settings that we would like to use. - modifies the iOS/Android specific push notification settings - adds a `flower` pod in the `docker-compose-developer.yml`, useful for debugging tasks locally - sets the mobile app verification token TTL to 5 minutes when developing locally. The default of 1 minute makes working with device emulators really tricky.. This PR also swaps out the base image in `engine/Dockerfile` from `python:3.9-alpine3.16` to `python:3.9-slim-buster`. As to why.. in short, with the introduction of the `fcm-django` library there is now a peer-dependency on [`grpcio`](https://github.com/grpc/grpc) (which is used by `firebase_admin`.. which I am using in this PR to interact directly with Firebase Cloud Messaging (FCM)). `grpcio` does not publish wheels (read: compiled binaries) for the Alpine distro. It does publish wheels for Debian and hence `pip install -r requirements.txt` does not need to build this library from the source distribution. This is a [known "issue"](https://github.com/grpc/grpc/issues/22815#issuecomment-1107874367) and the recommended solution in the community is to.. not use alpine. These were the numbers, when building the image locally, in terms of image size and build time: | | Local image size (uncompressed | Build time (may differ based on your network speed) | | ------------------------- | -------------------------------------- | ---------- | | `python:3.9-alpine3.16` | 785MB | 320s | | `python:3.9-slim-buster` | 1.05GB | 90s | Co-authored-by: Salvatore Giordano <salvatoregiordanoo@gmail.com>
157 lines
4.6 KiB
JavaScript
157 lines
4.6 KiB
JavaScript
const webpack = require('webpack');
|
|
const path = require('path');
|
|
|
|
const CircularDependencyPlugin = require('circular-dependency-plugin');
|
|
|
|
const MONACO_DIR = path.resolve(__dirname, './node_modules/monaco-editor');
|
|
|
|
Object.defineProperty(RegExp.prototype, 'toJSON', {
|
|
value: RegExp.prototype.toString,
|
|
});
|
|
|
|
module.exports.getWebpackConfig = (config, options) => {
|
|
const cssLoader = config.module.rules.find((rule) => rule.test.toString() === '/\\.css$/');
|
|
|
|
cssLoader.exclude.push(/\.module\.css$/, MONACO_DIR);
|
|
|
|
const grafanaRules = config.module.rules.filter((a) => a.test.toString() !== /\.s[ac]ss$/.toString());
|
|
|
|
const newConfig = {
|
|
...config,
|
|
module: {
|
|
...config.module,
|
|
rules: [
|
|
...grafanaRules,
|
|
|
|
{
|
|
test: /\.(ts|tsx)$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
{
|
|
loader: 'babel-loader',
|
|
options: {
|
|
cacheDirectory: true,
|
|
cacheCompression: false,
|
|
presets: [
|
|
[
|
|
'@babel/preset-env',
|
|
{
|
|
modules: false,
|
|
},
|
|
],
|
|
[
|
|
'@babel/preset-typescript',
|
|
{
|
|
allowNamespaces: true,
|
|
allowDeclareFields: true,
|
|
},
|
|
],
|
|
['@babel/preset-react'],
|
|
],
|
|
plugins: [
|
|
[
|
|
'@babel/plugin-transform-typescript',
|
|
{
|
|
allowNamespaces: true,
|
|
allowDeclareFields: true,
|
|
},
|
|
],
|
|
'@babel/plugin-proposal-class-properties',
|
|
[
|
|
'@babel/plugin-proposal-object-rest-spread',
|
|
{
|
|
loose: true,
|
|
},
|
|
],
|
|
[
|
|
'@babel/plugin-proposal-decorators',
|
|
{
|
|
legacy: true,
|
|
},
|
|
],
|
|
'@babel/plugin-transform-react-constant-elements',
|
|
'@babel/plugin-proposal-nullish-coalescing-operator',
|
|
'@babel/plugin-proposal-optional-chaining',
|
|
'@babel/plugin-syntax-dynamic-import',
|
|
],
|
|
},
|
|
},
|
|
'ts-loader',
|
|
],
|
|
},
|
|
|
|
{
|
|
test: /\.module\.css$/,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
sourceMap: true,
|
|
modules: {
|
|
localIdentName: options.production ? '[name]__[hash:base64]' : '[path][name]__[local]',
|
|
},
|
|
},
|
|
},
|
|
],
|
|
},
|
|
|
|
{
|
|
test: /\.module\.scss$/i,
|
|
exclude: /node_modules/,
|
|
use: [
|
|
'style-loader',
|
|
{
|
|
loader: 'css-loader',
|
|
options: {
|
|
importLoaders: 1,
|
|
sourceMap: true,
|
|
modules: {
|
|
localIdentName: options.production ? '[name]__[hash:base64]' : '[path][name]__[local]',
|
|
},
|
|
},
|
|
},
|
|
'postcss-loader',
|
|
'sass-loader',
|
|
],
|
|
},
|
|
],
|
|
},
|
|
|
|
plugins: [
|
|
...config.plugins,
|
|
new CircularDependencyPlugin({
|
|
// exclude detection of files based on a RegExp
|
|
exclude: /node_modules/,
|
|
// include specific files based on a RegExp
|
|
// add errors to webpack instead of warnings
|
|
failOnError: true,
|
|
// allow import cycles that include an asyncronous import,
|
|
// e.g. via import(/* webpackMode: "weak" */ './file.js')
|
|
allowAsyncCycles: false,
|
|
// set the current working directory for displaying module paths
|
|
cwd: process.cwd(),
|
|
}),
|
|
|
|
/**
|
|
* From docs (https://webpack.js.org/plugins/environment-plugin/):
|
|
* Default values of null and undefined behave differently.
|
|
* Use undefined for variables that must be provided during bundling, or null if they are optional.
|
|
*/
|
|
new webpack.EnvironmentPlugin({
|
|
ONCALL_API_URL: null,
|
|
MOBILE_APP_QR_INTERVAL_QUEUE: null,
|
|
}),
|
|
],
|
|
|
|
resolve: {
|
|
...config.resolve,
|
|
symlinks: false,
|
|
modules: [path.resolve(__dirname, './frontend_enterprise/src'), ...config.resolve.modules],
|
|
},
|
|
};
|
|
|
|
return newConfig;
|
|
};
|