diff --git a/dev/README.md b/dev/README.md index 43dbd87b0..2f580fd6f 100644 --- a/dev/README.md +++ b/dev/README.md @@ -76,10 +76,11 @@ Other containers might be restarted the same way. ## Browse the web UI -Open [the web UI](http://localhost:8001) in your favorite browser. +To develop: open [the development web UI](http://localhost:8002). This version has hot reload of UI code changes. -You can login with username `admin` and password `admin`. +To test build version: open [the web UI](http://localhost:8001) in your favorite browser. +You can login with username `admin` and password `admin`. ## Run tests diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 9c317e30b..625456738 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -41,6 +41,20 @@ services: ZIMFARM_WEBAPI: http://localhost:8000/v1 depends_on: - backend + frontend-ui-dev: + build: + dockerfile: ../../dev/frontend-ui-dev/Dockerfile + context: ../dispatcher/frontend-ui + # build: ../dispatcher/frontend-ui + container_name: zf_frontend-ui-dev + volumes: + - ../dispatcher/frontend-ui/src:/app/src + ports: + - 8002:80 + environment: + ZIMFARM_WEBAPI: http://localhost:8000/v1 + depends_on: + - backend backend-tools: build: dockerfile: ../../dev/backend-tools-tests/Dockerfile diff --git a/dev/frontend-ui-dev/Dockerfile b/dev/frontend-ui-dev/Dockerfile new file mode 100644 index 000000000..7e4d52267 --- /dev/null +++ b/dev/frontend-ui-dev/Dockerfile @@ -0,0 +1,14 @@ +FROM node:14-alpine as builder + +RUN apk --no-cache add yarn python3 +WORKDIR /app +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +COPY package.json yarn.lock /app/ +RUN yarn install && yarn cache clean +COPY *.js /app/ +COPY public /app/public +COPY src /app/src +#CMD ["sleep", "infinity"] +ENV ENVIRON_PATH /app/public/environ.json +ENTRYPOINT [ "entrypoint.sh" ] +CMD ["yarn", "serve", "--host", "0.0.0.0", "--port", "80"] \ No newline at end of file diff --git a/dispatcher/frontend-ui/entrypoint.sh b/dispatcher/frontend-ui/entrypoint.sh index 9dde45353..98da0f0fd 100755 --- a/dispatcher/frontend-ui/entrypoint.sh +++ b/dispatcher/frontend-ui/entrypoint.sh @@ -1,11 +1,14 @@ #!/bin/sh -JS_PATH=/usr/share/nginx/html/environ.json -echo "dump ZIMFARM_* environ variables to $JS_PATH" +if [ -z "${ENVIRON_PATH}" ] +then + ENVIRON_PATH=/usr/share/nginx/html/environ.json +fi +echo "dump ZIMFARM_* environ variables to $ENVIRON_PATH" -python3 -c 'import os; import json; print(json.dumps({k: v for k, v in os.environ.items() if k.startswith("ZIMFARM_")}, indent=4))' > $JS_PATH +python3 -c 'import os; import json; print(json.dumps({k: v for k, v in os.environ.items() if k.startswith("ZIMFARM_")}, indent=4))' > $ENVIRON_PATH -cat $JS_PATH +cat $ENVIRON_PATH echo "-----" exec "$@"