Skip to content

Commit

Permalink
Adaptations to have a local dev environment on port 8002
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit74 committed Sep 26, 2023
1 parent 1933310 commit 93725dc
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 3 additions & 2 deletions dev/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions dev/frontend-ui-dev/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
11 changes: 7 additions & 4 deletions dispatcher/frontend-ui/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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 "$@"

0 comments on commit 93725dc

Please sign in to comment.