diff --git a/docker-compose.yml b/docker-compose.yml index 4cc6749..be195fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,6 +16,8 @@ services: WEBSSH2_LOCATION: 'http://127.0.0.1:8081' ports: - "8080:80" + volumes: + - './src:/usr/share/nginx/html' # WebSSH2 is also required for terminal functionality - provides a websocket-to-ssh proxy for the front-end webssh2: image: "antidotelabs/webssh2:ping-timeout" diff --git a/hack/Dockerfile-dev b/hack/Dockerfile-dev index f5bd550..bacbc2c 100644 --- a/hack/Dockerfile-dev +++ b/hack/Dockerfile-dev @@ -1,9 +1,7 @@ # This is a DEVELOPMENT dockerfile, and therefore includes no npm build -# steps. It is assumed this has already been run, and therefore needs only -# a webserver. It is also not meant to be built directly, but rather through -# the provided Makefile ("make hack") +# steps. The build steps are accomplished by the dev.sh script in the +# /src/scripts directory. FROM nginx -COPY src/ /usr/share/nginx/html COPY launch.sh / CMD ["/launch.sh"] diff --git a/src/package.json b/src/package.json index ad23fd2..7b7d176 100644 --- a/src/package.json +++ b/src/package.json @@ -16,6 +16,10 @@ "rollup-plugin-terser": "^5.1.3" }, "scripts": { + "dev": "CLEAN_INSTALL=true COMPOSE_UP=true sh scripts/dev.sh", + "dev:up": "COMPOSE_UP=true sh scripts/dev.sh", + "dev:down": "COMPOSE_DOWN=true sh scripts/dev.sh", + "dev-restart": "COMPOSE_RESTART=true sh scripts/dev.sh", "build": "npx rollup -c", "watch": "npx rollup -cw", "test": "echo \"Error: no test specified\" && exit 1" diff --git a/src/scripts/dev.sh b/src/scripts/dev.sh new file mode 100755 index 0000000..e24074f --- /dev/null +++ b/src/scripts/dev.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# set -x # this line will enable debugs +ANTIDOTE_WEB_ENV=mock +export ANTIDOTE_WEB_ENV +if [ "$CLEAN_INSTALL" == "true" ]; then + # install deps + cd ../src + npm install + # This links the above antidote-ui-components into the src/node_modules directory + npm link ../../antidote-ui-components + # Cleanup + rm -rf advisor/ labs/ stats/ collections/ catalog/ + # Set up for a clean build + mkdir -p advisor/ labs/ stats/ collections/ catalog/ + cd ../templates + # Create the virtual python environment 'venv' + virtualenv venv/ + # Activate the virtual environment + source venv/bin/activate + pip install jinja2 + python generate_webapp.py + # Leave the virtual environment + deactivate +fi +if [ "$COMPOSE_UP" == "true" ]; then + docker-compose build --no-cache + docker-compose up -d + echo "Cluster started. Run 'docker-compose logs' to see log output." +fi +if [ "$COMPOSE_DOWN" == "true" ]; then + docker-compose down +fi +if [ "$COMPOSE_RESTART" == "true" ]; then + docker-compose down + docker-compose build --no-cache + docker-compose up -d + echo "Cluster started. Run 'docker-compose logs' to see log output." +fi