fix Docker image: separate static assets from build output
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,5 +3,5 @@ __pycache__
|
|||||||
*.pyc
|
*.pyc
|
||||||
.idea/
|
.idea/
|
||||||
**/node_modules/
|
**/node_modules/
|
||||||
static/
|
static/build/
|
||||||
*-secret
|
*-secret
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ RUN pip3 install -r /requirements.txt
|
|||||||
COPY app.py /
|
COPY app.py /
|
||||||
COPY templates /templates
|
COPY templates /templates
|
||||||
COPY app /app
|
COPY app /app
|
||||||
|
COPY static /static
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
RUN npm install && npm run build
|
RUN npm install && npm run build
|
||||||
|
|||||||
2
app.py
2
app.py
@@ -91,7 +91,7 @@ def health():
|
|||||||
@authorize
|
@authorize
|
||||||
def index():
|
def index():
|
||||||
app_js = None
|
app_js = None
|
||||||
for entry in os.listdir('static'):
|
for entry in os.listdir('static/build'):
|
||||||
if entry.startswith('app'):
|
if entry.startswith('app'):
|
||||||
app_js = entry
|
app_js = entry
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "=========================== Kubernetes Operational View ===========================",
|
"description": "=========================== Kubernetes Operational View ===========================",
|
||||||
"main": "src/app.js",
|
"main": "src/app.js",
|
||||||
"config": {
|
"config": {
|
||||||
"buildDir": "../static"
|
"buildDir": "../static/build"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prestart": "npm install",
|
"prestart": "npm install",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<!-- make sure the font is loaded -->
|
<!-- make sure the font is loaded -->
|
||||||
<div id="loading" style="font-family: ShareTechMono">Loading..</div>
|
<div id="loading" style="font-family: ShareTechMono">Loading..</div>
|
||||||
<script src="static/{{ app_js }}"></script>
|
<script src="static/build/{{ app_js }}"></script>
|
||||||
<script>document.getElementById('loading').style.display = 'none'; const app = new App(); app.run()</script>
|
<script>document.getElementById('loading').style.display = 'none'; const app = new App(); app.run()</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user