mirror of https://github.com/apache/superset.git
Docker-Compose Memory Issue Fix? (#9285)
* Adding free memory nag / running npm build with development options in compose * Adding license
This commit is contained in:
parent
1cbd955e79
commit
e9b0095754
|
@ -41,18 +41,23 @@ RUN cd /app \
|
||||||
######################################################################
|
######################################################################
|
||||||
FROM node:10-jessie AS superset-node
|
FROM node:10-jessie AS superset-node
|
||||||
|
|
||||||
|
ARG NPM_BUILD_CMD="build"
|
||||||
|
ENV BUILD_CMD=${NPM_BUILD_CMD}
|
||||||
|
|
||||||
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
|
# NPM ci first, as to NOT invalidate previous steps except for when package.json changes
|
||||||
RUN mkdir -p /app/superset-frontend
|
RUN mkdir -p /app/superset-frontend
|
||||||
RUN mkdir -p /app/superset/assets
|
RUN mkdir -p /app/superset/assets
|
||||||
|
COPY ./docker/frontend-mem-nag.sh /
|
||||||
COPY ./superset-frontend/package* /app/superset-frontend/
|
COPY ./superset-frontend/package* /app/superset-frontend/
|
||||||
RUN cd /app/superset-frontend \
|
RUN /frontend-mem-nag.sh \
|
||||||
|
&& cd /app/superset-frontend \
|
||||||
&& npm ci
|
&& npm ci
|
||||||
|
|
||||||
# Next, copy in the rest and let webpack do its thing
|
# Next, copy in the rest and let webpack do its thing
|
||||||
COPY ./superset-frontend /app/superset-frontend
|
COPY ./superset-frontend /app/superset-frontend
|
||||||
# This is BY FAR the most expensive step (thanks Terser!)
|
# This is BY FAR the most expensive step (thanks Terser!)
|
||||||
RUN cd /app/superset-frontend \
|
RUN cd /app/superset-frontend \
|
||||||
&& npm run build \
|
&& npm run ${BUILD_CMD} \
|
||||||
&& rm -rf node_modules
|
&& rm -rf node_modules
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
x-superset-build: &superset-build
|
x-superset-build: &superset-build
|
||||||
|
args:
|
||||||
|
NPM_BUILD_CMD: build-dev
|
||||||
context: ./
|
context: ./
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
target: dev
|
target: dev
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
# contributor license agreements. See the NOTICE file distributed with
|
||||||
|
# this work for additional information regarding copyright ownership.
|
||||||
|
# The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
# (the "License"); you may not use this file except in compliance with
|
||||||
|
# the License. You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# We need at least 3GB of free mem...
|
||||||
|
MIN_MEM_FREE_GB=3
|
||||||
|
MIN_MEM_FREE_KB=$(($MIN_MEM_FREE_GB*1000000))
|
||||||
|
|
||||||
|
echo_mem_warn() {
|
||||||
|
MEM_FREE_KB=$(awk '/MemFree/ { printf "%s \n", $2 }' /proc/meminfo)
|
||||||
|
MEM_FREE_GB=$(awk '/MemFree/ { printf "%s \n", $2/1024/1024 }' /proc/meminfo)
|
||||||
|
|
||||||
|
if [[ "${MEM_FREE_KB}" -lt "${MIN_MEM_FREE_KB}" ]]; then
|
||||||
|
cat <<EOF
|
||||||
|
===============================================
|
||||||
|
======== Memory Insufficient Warning =========
|
||||||
|
===============================================
|
||||||
|
|
||||||
|
It looks like you only have ${MEM_FREE_GB}GB of
|
||||||
|
memory free. Please increase your Docker
|
||||||
|
resources to at least ${MIN_MEM_FREE_GB}GB
|
||||||
|
|
||||||
|
===============================================
|
||||||
|
======== Memory Insufficient Warning =========
|
||||||
|
===============================================
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
echo "Memory check Ok [${MEM_FREE_GB}GB free]"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Always nag if they're low on mem...
|
||||||
|
echo_mem_warn
|
|
@ -14,6 +14,7 @@
|
||||||
"dev": "webpack --mode=development --colors --progress --debug --watch",
|
"dev": "webpack --mode=development --colors --progress --debug --watch",
|
||||||
"dev-server": "node --max_old_space_size=4096 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode=development --progress",
|
"dev-server": "node --max_old_space_size=4096 ./node_modules/webpack-dev-server/bin/webpack-dev-server.js --mode=development --progress",
|
||||||
"prod": "node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --mode=production --colors --progress",
|
"prod": "node --max_old_space_size=4096 ./node_modules/webpack/bin/webpack.js --mode=production --colors --progress",
|
||||||
|
"build-dev": "cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=development webpack --mode=development --colors --progress",
|
||||||
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=production webpack --mode=production --colors --progress",
|
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 NODE_ENV=production webpack --mode=production --colors --progress",
|
||||||
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
|
"lint": "eslint --ignore-path=.eslintignore --ext .js,.jsx,.ts,.tsx .",
|
||||||
"lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx . && npm run clean-css",
|
"lint-fix": "eslint --fix --ignore-path=.eslintignore --ext .js,.jsx,.ts,tsx . && npm run clean-css",
|
||||||
|
|
Loading…
Reference in New Issue