Skip to content

Commit 1f47f59

Browse files
authored
fix: use nodejs-lts image for building frontend code (zalando#2653)
* fix: use nodejs-lts image for building frontend code Node v14 is end-of-life and should no longer be used. Commit changes Makefile to pull in latest node-lts instead. Also, use local temporary folder for storing npm generated files to workaround permission issue with old npm version, e.g. emitting these errors: ``` npm ERR! code EACCES npm ERR! syscall mkdir npm ERR! path /.npm npm ERR! errno -13 npm ERR! npm ERR! Your cache folder contains root-owned files, due to a bug in npm ERR! previous versions of npm which has since been addressed. ``` Both changes should also fix issue zalando#2651 * fix: add frontend build step Commit zalando@d60b424 accidentally removed build steps that are important for building frontend. This commit restores previous behavior, but switches to nodejs-lts image for building frontend code. Should restore `app.js` presence in ghcr image, see zalando#2651.
1 parent 393439f commit 1f47f59

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,5 @@ e2e/tls
102102
*.pot
103103

104104
mocks
105+
106+
ui/.npm/

ui/.dockerignore

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
.git
66
__pycache__
77

8+
.npm/
9+
810
app/node_modules
911
operator_ui/static/build/*.hot-update.js
1012
operator_ui/static/build/*.hot-update.json

ui/Dockerfile

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
FROM registry.opensource.zalan.do/library/python-3.11-slim:latest
1+
ARG BASE_IMAGE=registry.opensource.zalan.do/library/python-3.11-slim:latest
2+
ARG NODE_IMAGE=node:lts-alpine
3+
4+
FROM $NODE_IMAGE AS build
5+
6+
COPY . /workdir
7+
WORKDIR /workdir/app
8+
9+
RUN npm install \
10+
&& npm run build
11+
12+
FROM $BASE_IMAGE
213
LABEL maintainer="Team ACID @ Zalando <[email protected]>"
314

415
EXPOSE 8081
@@ -15,6 +26,7 @@ COPY start_server.sh .
1526
RUN pip install -r requirements.txt
1627

1728
COPY operator_ui operator_ui/
29+
COPY --from=build /workdir/operator_ui/static/build/ operator_ui/static/build/
1830

1931
ARG VERSION=dev
2032
RUN sed -i "s/__version__ = .*/__version__ = '${VERSION}'/" operator_ui/__init__.py

ui/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ test:
2121
tox
2222

2323
appjs:
24-
docker run $(TTYFLAGS) -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:14.21.2-alpine npm install
25-
docker run $(TTYFLAGS) -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:14.21.2-alpine npm run build
24+
docker run $(TTYFLAGS) -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:lts-alpine npm install --cache /workdir/.npm
25+
docker run $(TTYFLAGS) -u $$(id -u) -v $$(pwd):/workdir -w /workdir/app node:lts-alpine npm run build --cache /workdir/.npm
2626

2727
docker: appjs
2828
echo `(env)`

0 commit comments

Comments
 (0)