diff --git a/Dockerfile b/Dockerfile index 603a6182f0..4e0db17242 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,6 @@ -FROM node:6 - -RUN apt-get update -RUN apt-get install --yes python2.7 git-all pkg-config libncurses5-dev libssl-dev libnss3-dev libexpat-dev libc6 +FROM node:9.5.0 WORKDIR /usr/src/app - -COPY package.json /usr/src/app/package.json - -RUN npm install -RUN npm install wrtc - COPY . /usr/src/app ENV IPFS_WRTC_LINUX_WINDOWS=1 @@ -17,9 +8,22 @@ ENV IPFS_BOOTSTRAP=1 ENV IPFS_MONITORING=1 ENV IPFS_PATH=/root/.jsipfs +ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3' + EXPOSE 4002 EXPOSE 4003 EXPOSE 5002 EXPOSE 9090 +RUN apt-get update \ + && apt-get install --yes $BUILD_DEPS \ + && rm -rf /var/lib/apt/lists/* \ + && npm install --production \ + && npm install wrtc@0.0.67 --production \ + && npm cache clear --force \ + && apt-get purge --yes $BUILD_DEPS \ + && rm -rf /usr/share/doc /usr/share/locale \ + && rm -rf /usr/local/share/.cache \ + && rm -rf node_modules/go-ipfs-dep/go-ipfs/ipfs + CMD ./init-and-daemon.sh diff --git a/init-and-daemon.sh b/init-and-daemon.sh index a01721e436..0085bce4a5 100755 --- a/init-and-daemon.sh +++ b/init-and-daemon.sh @@ -1,6 +1,18 @@ -#! /bin/sh -e -node src/cli/bin.js init +#! /usr/bin/env bash + +set -e + +if [ -n $IPFS_PATH ]; then + echo "Using $IPFS_PATH as IPFS repository" +else + echo "You need to set IPFS_PATH environment variable to use this script" + exit 1 +fi sed -i.bak 's/127.0.0.1/0.0.0.0/g' $IPFS_PATH/config +# Initialize the repo but ignore if error if it already exists +# This can be the case when we restart a container without stopping/removing it +node src/cli/bin.js init || true + node src/cli/bin.js daemon