Skip to content
This repository has been archived by the owner on Apr 21, 2024. It is now read-only.

Commit

Permalink
Install chromium-browser to make debug support(node-inspector)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkbase committed Nov 11, 2016
1 parent f11b64e commit 7a1d140
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions develop-tools/nodejs-debug/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.runtime/
38 changes: 38 additions & 0 deletions develop-tools/nodejs-debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# NodeJS and npm, with chromium-browser, As the basic environment for development
# ----
# build image:
# docker build --force-rm -t platbase.com/dev.nodejs-debug:1.0 .
# run:
# docker run -it --rm -p 8080:8080 \
# -v /tmp/nodejs.ws:/workspace -v /tmp/nodejs.data:/data \
# -v /tmp/.X11-unix:/tmp/.X11-unix platbase.com/dev.nodejs-debug:1.0

FROM platbase.com/dev.nodejs:1.0
MAINTAINER https://github.com/platbase

# Mappings
EXPOSE 8080
VOLUME ["/workspace", "/data", "/tmp/.X11-unix"]

# DISPLAY
ENV DISPLAY ":0"

# Entry - force work with user "u01"
CMD /start-nodejs-shell.sh

###############################################################################

# make sure the package repository is up to date
RUN apt-get update

# Install zh-CN support
RUN apt-get install -y language-pack-zh-hans
RUN apt-get install -y ttf-ubuntu-font-family
RUN apt-get install -y ttf-wqy-zenhei ttf-wqy-microhei

# Install Chromium
RUN apt-get install -y chromium-browser

# Prepare starting commands
ADD files/start-nodejs-shell.sh /start-nodejs-shell.sh
RUN chmod +x /start-nodejs-shell.sh
28 changes: 28 additions & 0 deletions develop-tools/nodejs-debug/docker-node.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

# SHELL_ROOT - Location(Path) of this batch file
SHELL_ROOT=$(cd "$(dirname "$0")"; pwd)

mkdir -p "${SHELL_ROOT}/.runtime/cache"
mkdir -p "${SHELL_ROOT}/.runtime/global"
touch "${SHELL_ROOT}/.runtime/devops.platbase.com-docker-data"

# Find avaliable ports between 8080 to 9080
LOWERPORT=8080
UPPERPORT=9080
# FIXME: "netstat -ntpl" warning:
# Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all..
lp=null
for (( port = LOWERPORT ; port <= UPPERPORT ; port++ )); do
netstat -ntpl 2>/dev/null | grep ":$port "
[ $? -eq 1 ] && { lp=$port; break; }
done
[ "$lp" = "null" ] && { echo "No free local ports available(between $LOWERPORT and $UPPERPORT)"; exit 2; }

echo ">>> Find avaliable local port: $port ."

docker run -it --rm -p $port:8080 \
-v "`pwd`":/workspace \
-v "${SHELL_ROOT}/.runtime":/data \
-v /tmp/.X11-unix:/tmp/.X11-unix \
platbase.com/dev.nodejs-debug:1.0
22 changes: 22 additions & 0 deletions develop-tools/nodejs-debug/files/start-nodejs-shell.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
echo "*** Development environment with NodeJS and Npm ***"
set -o errexit

# Env setup
/docker-base-init/docker-boot

/docker-base-init/set-PS1 NodeJS
/docker-base-init/set-CMD "cd /workspace"
/docker-base-init/set-PATH "./node_modules/.bin:/data/global/bin"
/docker-base-init/set-PATH "/opt/nodejs/node-v${VERSION}-linux-x64/bin:/opt/nodejs/node-v${VERSION}-linux-x64/bin/npm-global/bin"

# Save Chromium profile to /data/.chromium
echo ">>> Redirect chromium profile directory to /data ..."
mkdir -p /home/u01/.config; chown u01:u01 /home/u01/.config
mkdir -p /data/.chromium; chown u01:u01 /data/.chromium
ln -s /data/.chromium /home/u01/.config/chromium
ls -al ~u01/.config/chromium

echo "========"

su - u01

0 comments on commit 7a1d140

Please sign in to comment.