Skip to content

Commit

Permalink
Created make target dev_image to support Erik's local container workf…
Browse files Browse the repository at this point in the history
…low, and updated docs to reflect this.
  • Loading branch information
sychan committed Jun 7, 2018
1 parent 61d31fb commit f380dd1
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 17 deletions.
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ ARG BUILD_DATE
ARG VCS_REF
ARG BRANCH=develop
ARG NARRATIVE_VERSION
ARG SKIP_MINIFY

EXPOSE 8888

# Remove Debian's older Tornado package - updated/removed in the narrbase package
#RUN DEBIAN_FRONTEND=noninteractive apt-get remove -y python-tornado

RUN echo Skip=$SKIP_MINIFY

# install pyopenssl cryptography idna and requests is the same as installing
# requests[security]
RUN conda install -c conda-forge ndg-httpsclient pyasn1 pyopenssl cryptography idna requests \
Expand All @@ -49,12 +52,11 @@ RUN mkdir -p /kb/deployment/ui-common/ && ./src/scripts/kb-update-config -f src/
# Install Javascript dependencies
RUN npm install && bower install --allow-root --config.interactive=false

# Compile Javascript down into an itty-bitty ball.
# Compile Javascript down into an itty-bitty ball unless SKIP_MINIFY is non-empty
# (commented out for now)
# RUN cd kbase-extension/
# src/notebook/ipython_profiles/profile_narrative/kbase_templates && npm install && grunt build
RUN grunt minify

RUN [ -n "$SKIP_MINIFY" ] || grunt minify

# Add Tini. Tini operates as a process subreaper for jupyter. This prevents
# kernel crashes. See Jupyter Notebook known issues here:˜
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ build-narrative-container:

docker_image: build-narrative-container

# Per PR #1328, adding an option to skip minification
dev_image:
SKIP_MINIFY=1 DOCKER_TAG=dev sh $(DOCKER_INSTALLER)

install:
@echo "Installing local Narrative in the $(INSTALL_VENV) virtual environment"
bash $(INSTALLER) -v $(INSTALL_VENV)
Expand Down
13 changes: 3 additions & 10 deletions docs/developer/local-docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,8 @@ It is useful to run the Narrative within a local docker container. E.g. this mak

The following changes are required:

- omit the line `RUN grunt minify` from /Dockerfile

- build the image manually.

The makefile has a tag of 1.0.3, we don't need that, so just use a more convenient "dev" tag for local usage.

```bash
docker build -t kbase/narrative:dev .
```
- Build the docker image using the make target "dev_image", this builds the docker image without the "grunt minify" step.
The image will be tagged kbase/narrative:dev instead of the current git branch

- start the container using the `scripts/local-dev-run.sh` script.

Expand All @@ -26,7 +19,7 @@ The following changes are required:
env=ci bash scripts/local-dev-run.sh
```

where env sets the ENVIRON environment variable for the Docker container; ci is the environment in which you are working (needs to be same as the ui is running on.)
where env sets the CONFIG_ENV environment variable for the Docker container; ci is the environment in which you are working (needs to be same as the ui is running on.)

- uses the config set $env; makes it easy to test different environments alongside ui
- uses kbase-dev network; allows interoperation with the kbase-ui proxier
Expand Down
13 changes: 10 additions & 3 deletions scripts/build_narrative_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ NAR_VER_NAME="kbase/narrative_version" # Image for serving up the narrative ver
HEADLESS_NAME="kbase/narrative_headless"
NAR_BASE="kbase/narrbase"
NAR_BASE_VER="5.0dockerize"
NARRATIVE_VER="dockerize"

# Get the current branch, so that we can tag images to branch
BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`}
# Use the branch unless we aere given am explicit DOCKER_TAG
NARRATIVE_VER=${DOCKER_TAG:-$BRANCH}
COMMIT=`git rev-parse --short HEAD`

#NAR_PREREQ="kbase/narrprereq"
Expand Down Expand Up @@ -83,17 +87,19 @@ echo "Building latest narrative version"
# narrative runner
export NARRATIVE_VERSION_NUM=`grep '\"version\":' src/config.json.templ | awk '{print $2}' | sed 's/"//g'`
export DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
export COMMIT=`git rev-parse --short HEAD`
export BRANCH=${TRAVIS_BRANCH:-`git symbolic-ref --short HEAD`}

docker build -t $NAR_NAME:$NARRATIVE_VER \
--build-arg BUILD_DATE=$DATE \
--build-arg VCS_REF=$COMMIT \
--build-arg BRANCH=$BRANCH \
--build-arg NARRATIVE_VERSION=$NARRATIVE_VERSION_NUM \
--build-arg BRANCH=$BRANCH \
--build-arg SKIP_MINIFY=$SKIP_MINIFY \
.
docker tag $NAR_NAME:$NARRATIVE_VER $NAR_NAME:$COMMIT

# Give the image a fixed name because dockfile FROM fields cannot take a variable/argument
# and we're using the output from the previous build in this 2nd container
docker tag $NAR_NAME:$NARRATIVE_VER kbase/narrative:tmp
docker build -t $NAR_VER_NAME:$NARRATIVE_VER \
--build-arg BUILD_DATE=$DATE \
Expand All @@ -104,6 +110,7 @@ docker build -t $NAR_VER_NAME:$NARRATIVE_VER \
-f Dockerfile2 \
.
docker tag $NAR_VER_NAME:$NARRATIVE_VER $NAR_VER_NAME:$COMMIT
docker rmi kbase/narrative:tmp

# Remove any provisioned, but not used, containers
curl -k -X DELETE https://localhost/proxy_map/provisioned || echo "Ignore Error"
2 changes: 1 addition & 1 deletion scripts/local-dev-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ -z $env ]; then
fi
docker run \
--dns=8.8.8.8 \
-e "ENVIRON=${env}" \
-e "CONFIG_ENV=${env}" \
--network=kbase-dev \
--name=narrative \
--mount type=bind,src=${root}/${static_dir},dst=${container_root}/${static_dir} \
Expand Down

0 comments on commit f380dd1

Please sign in to comment.