From 6c8b38b756739b09f91505dd6f2a4342b2c23089 Mon Sep 17 00:00:00 2001 From: kev Date: Sat, 16 Jan 2016 12:07:47 +0800 Subject: [PATCH] fix nodebb --- README.md | 2 +- nodebb/Dockerfile | 2 +- nodebb/Dockerfile.debian | 43 +++++++++++++++++++++++++++++++++ nodebb/README.md | 6 +++++ nodebb/arm/Dockerfile | 1 - nodebb/arm/Dockerfile.debian | 43 +++++++++++++++++++++++++++++++++ nodebb/arm/config.example.json | 11 --------- nodebb/arm/docker-entrypoint.sh | 12 ++++++--- nodebb/config.example.json | 11 --------- nodebb/docker-entrypoint.sh | 12 ++++++--- 10 files changed, 110 insertions(+), 33 deletions(-) create mode 100644 nodebb/Dockerfile.debian create mode 100644 nodebb/arm/Dockerfile.debian delete mode 100644 nodebb/arm/config.example.json delete mode 100644 nodebb/config.example.json diff --git a/README.md b/README.md index 802df9d..e39398d 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ dockerfiles - [x] nginad - [x] nginx - [x] ngrok :+1: -- [x] nodebb +- [x] nodebb :+1: - [x] node-red :+1: - [x] node-red-arm :+1: - [x] obfsproxy diff --git a/nodebb/Dockerfile b/nodebb/Dockerfile index 4428d45..59578c0 100644 --- a/nodebb/Dockerfile +++ b/nodebb/Dockerfile @@ -27,12 +27,12 @@ RUN set -ex \ && curl -sSL $BB_URL | tar xz --strip 1 \ && sed -i '/"bufferutil": {/,/},/d; /"utf-8-validate": {/,/},/d' npm-shrinkwrap.json \ && npm install --production \ + && npm install connect-redis \ && npm cache clean \ && apk del TMP \ && rm -rf /tmp/npm* \ /var/cache/apk/* -COPY config.example.json $BB_SOURCE COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/nodebb/Dockerfile.debian b/nodebb/Dockerfile.debian new file mode 100644 index 0000000..3b4fd41 --- /dev/null +++ b/nodebb/Dockerfile.debian @@ -0,0 +1,43 @@ +# +# Dockerfile for nodebb +# + +FROM debian +MAINTAINER kev + +ENV BB_VER 0.9.3 +ENV BB_URL https://github.com/NodeBB/NodeBB/archive/v$BB_VER.tar.gz +ENV BB_SOURCE /usr/src/nodebb +ENV BB_CONTENT /var/lib/nodebb + +WORKDIR $BB_SOURCE +VOLUME $BB_CONTENT + +RUN set -ex \ + && apt-get update \ + && apt-get install -y build-essential \ + curl \ + git \ + imagemagick \ + libssl1.0.0 \ + libssl-dev \ + python \ + && curl -sSL https://deb.nodesource.com/setup_4.x | bash - \ + && apt-get install -y nodejs \ + && curl -sSL $BB_URL | tar xz --strip 1 \ + && sed -i '/"bufferutil": {/,/},/d; /"utf-8-validate": {/,/},/d' npm-shrinkwrap.json \ + && npm install --production \ + && npm cache clean \ + && apt-get remove -y build-essential \ + curl \ + git \ + libssl-dev \ + python \ + && rm -rf /tmp/npm* \ + /var/cache/apt/* + +COPY docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 4567 +CMD ["npm", "start"] diff --git a/nodebb/README.md b/nodebb/README.md index eec82f7..f8fa68d 100644 --- a/nodebb/README.md +++ b/nodebb/README.md @@ -30,4 +30,10 @@ $ docker-compose up -d $ firefox http://localhost:4567 ``` +## todo + +- Next release: install + - alpine: krb5-libs krb5-dev + - debian: libkrb5-3 libkrb5-dev + [1]: https://nodebb.org/ diff --git a/nodebb/arm/Dockerfile b/nodebb/arm/Dockerfile index f390227..ee64da9 100644 --- a/nodebb/arm/Dockerfile +++ b/nodebb/arm/Dockerfile @@ -32,7 +32,6 @@ RUN set -ex \ && rm -rf /tmp/npm* \ /var/cache/apk/* -COPY config.example.json $BB_SOURCE COPY docker-entrypoint.sh /entrypoint.sh ENTRYPOINT ["/entrypoint.sh"] diff --git a/nodebb/arm/Dockerfile.debian b/nodebb/arm/Dockerfile.debian new file mode 100644 index 0000000..a487a4e --- /dev/null +++ b/nodebb/arm/Dockerfile.debian @@ -0,0 +1,43 @@ +# +# Dockerfile for nodebb-arm +# + +FROM resin/rpi-raspbian +MAINTAINER kev + +ENV BB_VER 0.9.3 +ENV BB_URL https://github.com/NodeBB/NodeBB/archive/v$BB_VER.tar.gz +ENV BB_SOURCE /usr/src/nodebb +ENV BB_CONTENT /var/lib/nodebb + +WORKDIR $BB_SOURCE +VOLUME $BB_CONTENT + +RUN set -ex \ + && apt-get update \ + && apt-get install -y build-essential \ + curl \ + git \ + imagemagick \ + libssl1.0.0 \ + libssl-dev \ + python \ + && curl -sSL https://deb.nodesource.com/setup_4.x | bash - \ + && apt-get install -y nodejs \ + && curl -sSL $BB_URL | tar xz --strip 1 \ + && sed -i '/"bufferutil": {/,/},/d; /"utf-8-validate": {/,/},/d' npm-shrinkwrap.json \ + && npm install --production \ + && npm cache clean \ + && apt-get remove -y build-essential \ + curl \ + git \ + libssl-dev \ + python \ + && rm -rf /tmp/npm* \ + /var/cache/apt/* + +COPY docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] + +EXPOSE 4567 +CMD ["npm", "start"] diff --git a/nodebb/arm/config.example.json b/nodebb/arm/config.example.json deleted file mode 100644 index ebf4e86..0000000 --- a/nodebb/arm/config.example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "url": "http://localhost:4567", - "secret": "SECRET", - "database": "redis", - "redis": { - "host": "redis", - "port": "6379", - "password": "", - "database": "0" - } -} diff --git a/nodebb/arm/docker-entrypoint.sh b/nodebb/arm/docker-entrypoint.sh index 9f68f2c..28f4d78 100755 --- a/nodebb/arm/docker-entrypoint.sh +++ b/nodebb/arm/docker-entrypoint.sh @@ -7,12 +7,16 @@ export daemon=false if [[ "$*" == npm*start* ]]; then if [ ! -e "$BB_CONTENT/config.json" ]; then - sed "s/SECRET/$(node -e 'console.log(require("node-uuid").v4())')/" \ - "$BB_SOURCE/config.example.json" > "$BB_CONTENT/config.json" - npm install connect-redis + if [ -e "$BB_SOURCE/config.json" ]; then + cp "$BB_SOURCE/config.json" "$BB_CONTENT/config.json" + fi fi - ln -sf "$BB_CONTENT/config.json" "$BB_SOURCE/config.json" + if [ -e "$BB_CONTENT/config.json" ]; then + ln -sf "$BB_CONTENT/config.json" "$BB_SOURCE/config.json" + [ -d "$BB_SOURCE/node_modules/redis" ] || npm install redis + [ -d "$BB_SOURCE/node_modules/connect-redis" ] || npm install connect-redis + fi exec "$@" fi diff --git a/nodebb/config.example.json b/nodebb/config.example.json deleted file mode 100644 index ebf4e86..0000000 --- a/nodebb/config.example.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "url": "http://localhost:4567", - "secret": "SECRET", - "database": "redis", - "redis": { - "host": "redis", - "port": "6379", - "password": "", - "database": "0" - } -} diff --git a/nodebb/docker-entrypoint.sh b/nodebb/docker-entrypoint.sh index 9f68f2c..28f4d78 100755 --- a/nodebb/docker-entrypoint.sh +++ b/nodebb/docker-entrypoint.sh @@ -7,12 +7,16 @@ export daemon=false if [[ "$*" == npm*start* ]]; then if [ ! -e "$BB_CONTENT/config.json" ]; then - sed "s/SECRET/$(node -e 'console.log(require("node-uuid").v4())')/" \ - "$BB_SOURCE/config.example.json" > "$BB_CONTENT/config.json" - npm install connect-redis + if [ -e "$BB_SOURCE/config.json" ]; then + cp "$BB_SOURCE/config.json" "$BB_CONTENT/config.json" + fi fi - ln -sf "$BB_CONTENT/config.json" "$BB_SOURCE/config.json" + if [ -e "$BB_CONTENT/config.json" ]; then + ln -sf "$BB_CONTENT/config.json" "$BB_SOURCE/config.json" + [ -d "$BB_SOURCE/node_modules/redis" ] || npm install redis + [ -d "$BB_SOURCE/node_modules/connect-redis" ] || npm install connect-redis + fi exec "$@" fi