Skip to content

Instantly share code, notes, and snippets.

@bbuechler
Last active August 24, 2020 21:32
Show Gist options
  • Save bbuechler/7614dca4a191da3d7dd23e55d1642148 to your computer and use it in GitHub Desktop.
Save bbuechler/7614dca4a191da3d7dd23e55d1642148 to your computer and use it in GitHub Desktop.
Build & Run Dashboard in docker
FROM nginx
RUN apt-get update && apt-get -y install nodejs npm nodejs curl git rsync
STOPSIGNAL SIGQUIT
COPY docker/nginx.conf /etc/nginx/nginx.conf
COPY docker/run-nginx.sh /usr/local/sbin/run-nginx.sh
RUN rm -rf /cumulus-dashboard/
COPY . /cumulus-dashboard/
# Build inptu
ARG NODE_VERSION
ENV NODE_VERSION=$NODE_VERSION
ARG APIROOT
ENV APIROOT=$APIROOT
ARG DAAC_NAME
ENV DAAC_NAME=$DAAC_NAME
ARG STAGE
ENV STAGE=$STAGE
ARG HIDE_PDR
ENV HIDE_PDR=$HIDE_PDR
ARG LABELS
ENV LABELS=$LABELS
ARG SERVED_BY_CUMULUS_API
ENV SERVED_BY_CUMULUS_API=$SERVED_BY_CUMULUS_API
ARG AUTH_METHOD
ENV AUTH_METHOD=$AUTH_METHOD
ENV NVM_DIR /usr/local/nvm
RUN npm install npm@latest -g
RUN cd /cumulus-dashboard && \
npm install && \
APIROOT=$APIROOT \
DAAC_NAME=$DAAC_NAME \
STAGE=$STAGE \
HIDE_PDR=$HIDE_PDR \
LABELS=$LABELS \
SERVED_BY_CUMULUS_API=$SERVED_BY_CUMULUS_API \
AUTH_METHOD=$AUTH_METHOD npm run build
RUN cp -r /cumulus-dashboard/dist/* /usr/share/nginx/html/
CMD ["/usr/local/sbin/run-nginx.sh"]

Build & Run Cumulus Dashboard in docker

Clone Dashboard

Instructions below are for dashboard v1.8.0 but you should be able to do other versions by checking out the appropriate tag and adjusting NODE_VERSION (Below) as appropriate. Check Supported PI Versions for Dashboard & Cumulus compatability.
As an example: Cumulus Version 1.19 should us Dashboard releasae v1.7.2 & NODE_VERSION="10.x".

git clone https://github.com/nasa/cumulus-dashboard
cd cumulus-dashboard
# Grab the tags...
git fetch --all --tags
# This dockerfile was crafted to work with cumulus dashboard 1.8.0
git checkout tags/v1.8.0

Copy standalone.dockerfile to cumulus-dashboard/docker/

Manually download the standalone.dockerfile or use curl to fetch it

cd docker/
curl -L https://gist.githubusercontent.com/bbuechler/7614dca4a191da3d7dd23e55d1642148/raw/bb0a7733ba1f99625bbe9777c4d1e9cf5fd413ea/standalone.dockerfile -O 

Export your API URL

See Pull the API name from the CloudFormation Stack for details on getting this value.

export APIROOT=https://w37g32wack.execute-api.us-east-1.amazonaws.com/test/

Build Docker Container

Be sure to adjust the build-args as appropriate. Pay particular attention to NODE_VERSION. Cumulus version 1.10.0 and higher should use NODE_VERSION="12.x".

cd ..
docker build \
  --build-arg NODE_VERSION="10.x" \
  --build-arg APIROOT=$APIROOT \
  --build-arg DAAC_NAME="YourDaac" \
  --build-arg STAGE=dev \
  --build-arg HIDE_PDR=false \
  --build-arg LABELS=daac \
  --build-arg SERVED_BY_CUMULUS_API=false \
  --build-arg AUTH_METHOD=earthdata \
  -f docker/standalone.dockerfile \
  -t cumulusdash .

Start Docker Container

export cumulusdash=$(docker run -e PORT=8181 -p 8181:8181 -d cumulusdash)

(Optional) Configure NGAP Bastion Tunnel & Firefox:

Check out PROXY.md

Open firefox and navigate to http://localhost:8181

Hey! Its the cumulus Dashboard!

(Optional) Copy build html from container and upload to a bucket:

This is helpful if you want to serve your dashboard from a cloudfront endpoint or s3-website

# copy the nginx html file to a local directory
mkdir /tmp/dashboard && docker cp $cumulusdash:/usr/share/nginx/html/ /tmp/dashboard/

# Sync the html directory up to an S3 bucket:
aws s3 sync /tmp/dashboard/html/ s3://your-cumulus-html-bucket

When you're finished with your container, stop it

docker kill $cumulusdash

Gotchas

  • Make sure your TOKEN_REDIRECT_ENDPOINT value is added to the URS APP as a redirect_uri
  • If your var.archive_api_port value is set to 8000, the Proxy.pac config won't work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment