From 3fb3acaade9cd0f4aae0fde316cfc2ad21a9c62f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Jedynak?= Date: Fri, 26 Jan 2024 14:45:04 +0000 Subject: [PATCH] Remove unnecessary copies in dockerfiles (#366) * Remove unnecessary copies in dockerfiles * Fix the monaco loader * Make it Prettier --- deploy/docker/dev.frontend.Dockerfile | 3 +-- deploy/docker/web.Dockerfile | 4 +--- src/mqueryfront/package.json | 4 ++-- src/mqueryfront/src/query/QueryMonaco.js | 11 ++++++----- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/deploy/docker/dev.frontend.Dockerfile b/deploy/docker/dev.frontend.Dockerfile index 52a1a132..45517b8f 100644 --- a/deploy/docker/dev.frontend.Dockerfile +++ b/deploy/docker/dev.frontend.Dockerfile @@ -3,6 +3,5 @@ FROM node:16 AS build RUN npm install -g serve COPY src/mqueryfront /app WORKDIR /app -RUN npm install --legacy-peer-deps && \ - cp -r ./node_modules/monaco-editor/min/vs ./public/monaco-vs +RUN npm install --legacy-peer-deps CMD ["npm", "start"] diff --git a/deploy/docker/web.Dockerfile b/deploy/docker/web.Dockerfile index fc5cd81b..18d3b759 100644 --- a/deploy/docker/web.Dockerfile +++ b/deploy/docker/web.Dockerfile @@ -3,9 +3,7 @@ FROM node:16 AS build RUN npm install -g serve COPY src/mqueryfront /app WORKDIR /app -RUN npm install --legacy-peer-deps && \ - cp -r ./node_modules/monaco-editor/min/vs ./public/monaco-vs && \ - npm run build +RUN npm install --legacy-peer-deps && npm run build FROM python:3.10 diff --git a/src/mqueryfront/package.json b/src/mqueryfront/package.json index c59589eb..bd29ba81 100644 --- a/src/mqueryfront/package.json +++ b/src/mqueryfront/package.json @@ -7,8 +7,8 @@ "@fortawesome/fontawesome-svg-core": "^1.2.36", "@fortawesome/free-solid-svg-icons": "^5.15.4", "@fortawesome/react-fontawesome": "^0.1.16", - "@monaco-editor/react": "3.7.5", - "monaco-editor": "^0.21.2", + "@monaco-editor/react": "^4.4.6", + "monaco-editor": "^0.34.1", "axios": "^1.3.4", "bootstrap": "^5.1.3", "filesize": "^8.0.6", diff --git a/src/mqueryfront/src/query/QueryMonaco.js b/src/mqueryfront/src/query/QueryMonaco.js index 9dcc7d7b..67b5bd1f 100644 --- a/src/mqueryfront/src/query/QueryMonaco.js +++ b/src/mqueryfront/src/query/QueryMonaco.js @@ -1,8 +1,9 @@ import React, { Component } from "react"; -import Editor, { monaco } from "@monaco-editor/react"; +import * as monaco from "monaco-editor/esm/vs/editor/edcore.main"; +import Editor, { loader } from "@monaco-editor/react"; import YARA from "./yara-lang"; -monaco.config({ paths: { vs: "/monaco-vs" } }); +loader.config({ monaco }); class QueryMonaco extends Component { constructor(props) { @@ -17,7 +18,7 @@ class QueryMonaco extends Component { return; } - monaco.init().then((monaco) => { + loader.init().then((monaco) => { this.decorations = this.editor.getModel().deltaDecorations( [], [ @@ -42,7 +43,7 @@ class QueryMonaco extends Component { handleEditorDidMount(_, editor) { this.editor = editor; - monaco + loader .init() .then((monaco) => { editor.onDidChangeModelContent((ev) => { @@ -122,7 +123,7 @@ class QueryMonaco extends Component { * Monaco editor initialization */ -monaco.init().then((monaco) => { +loader.init().then((monaco) => { // Register a new yara language monaco.languages.register({ id: "yara" });