Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 2d36155

Browse files
victorbJonKrone
authored andcommitted
Various improvements to Docker Image
- Smaller size (from 1.52GB to 875MB) - Ignore errors with init as repository could already be initialized if we restart a running container for example - Locks down version of wrtc - Upgrade from node@6 to node@9.5 Docker
1 parent ceb8246 commit 2d36155

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

Dockerfile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
FROM node:6
2-
3-
RUN apt-get update
4-
RUN apt-get install --yes python2.7 git-all pkg-config libncurses5-dev libssl-dev libnss3-dev libexpat-dev libc6
1+
FROM node:9.5.0
52

63
WORKDIR /usr/src/app
7-
8-
COPY package.json /usr/src/app/package.json
9-
10-
RUN npm install
11-
RUN npm install wrtc
12-
134
COPY . /usr/src/app
145

156
ENV IPFS_WRTC_LINUX_WINDOWS=1
167
ENV IPFS_BOOTSTRAP=1
178
ENV IPFS_MONITORING=1
189
ENV IPFS_PATH=/root/.jsipfs
1910

11+
ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3'
12+
2013
EXPOSE 4002
2114
EXPOSE 4003
2215
EXPOSE 5002
2316
EXPOSE 9090
2417

18+
RUN apt-get update \
19+
&& apt-get install --yes $BUILD_DEPS \
20+
&& rm -rf /var/lib/apt/lists/* \
21+
&& npm install --production \
22+
&& npm install wrtc@0.0.67 --production \
23+
&& npm cache clear --force \
24+
&& apt-get purge --yes $BUILD_DEPS \
25+
&& rm -rf /usr/share/doc /usr/share/locale \
26+
&& rm -rf /usr/local/share/.cache \
27+
&& rm -rf node_modules/go-ipfs-dep/go-ipfs/ipfs
28+
2529
CMD ./init-and-daemon.sh

init-and-daemon.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
#! /bin/sh -e
2-
node src/cli/bin.js init
1+
#! /usr/bin/env bash
2+
3+
set -e
4+
5+
if [ -n $IPFS_PATH ]; then
6+
echo "Using $IPFS_PATH as IPFS repository"
7+
else
8+
echo "You need to set IPFS_PATH environment variable to use this script"
9+
exit 1
10+
fi
311

412
sed -i.bak 's/127.0.0.1/0.0.0.0/g' $IPFS_PATH/config
513

14+
# Initialize the repo but ignore if error if it already exists
15+
# This can be the case when we restart a container without stopping/removing it
16+
node src/cli/bin.js init || true
17+
618
node src/cli/bin.js daemon

0 commit comments

Comments
 (0)