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

improve dockerfiles #4275

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
*

!entrypoint.sh
32 changes: 15 additions & 17 deletions Dockerfile.latest
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,24 @@ ENV IPFS_MONITORING=1
ENV IPFS_PATH=/root/.jsipfs
ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3'

RUN apk add --no-cache git python3 build-base

# Hopefully remove when https://github.com/node-webrtc/node-webrtc/pull/694 is merged
RUN npm install -g ipfs@"$IPFS_VERSION"

# Make the image a bit smaller
RUN npm cache clear --force
RUN apk del build-base python3 git

# Configure jsipfs
RUN jsipfs init

RUN jsipfs version

# Allow connections from any host
RUN sed -i.bak "s/127.0.0.1/0.0.0.0/g" $IPFS_PATH/config
RUN \
apk add --no-cache catatonit bash procps nodejs npm \
sevenrats marked this conversation as resolved.
Show resolved Hide resolved
build-base python3 && \
npm install -g --build-from-source ipfs@"$IPFS_VERSION" && \
npm cache clear --force && \
apk del build-base python3 make npm && \
rm -rf /node-* /SHASUMS256.txt /tmp/* /root/.electron /root/.cache \
/sbin/apk /etc/apk /lib/apk /usr/share/apk /var/lib/apk \
/usr/share/man/* /usr/share/doc /root/.npm /root/.node-gyp /root/.config \
/usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/docs \
/usr/lib/node_modules/npm/html /usr/lib/node_modules/npm/scripts && \
{ rm -rf /root/.gnupg || true; }

EXPOSE 4002
EXPOSE 4003
EXPOSE 5002
EXPOSE 9090

CMD jsipfs daemon
COPY entrypoint.sh /entrypoint.sh

CMD ["catatonit", "/entrypoint.sh"]
34 changes: 16 additions & 18 deletions Dockerfile.next
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
FROM node:16-alpine
FROM alpine

ENV IPFS_VERSION=next
ENV IPFS_MONITORING=1
ENV IPFS_PATH=/root/.jsipfs
ENV BUILD_DEPS='libnspr4 libnspr4-dev libnss3'

RUN apk add --no-cache git python3 build-base

# Hopefully remove when https://github.com/node-webrtc/node-webrtc/pull/694 is merged
RUN npm install -g ipfs@"$IPFS_VERSION"

# Make the image a bit smaller
RUN npm cache clear --force
RUN apk del build-base python3 git

# Configure jsipfs
RUN jsipfs init

RUN jsipfs version

# Allow connections from any host
RUN sed -i.bak "s/127.0.0.1/0.0.0.0/g" $IPFS_PATH/config
RUN \
apk add --no-cache catatonit bash procps nodejs npm \
build-base python3 && \
npm install -g --build-from-source ipfs@"$IPFS_VERSION" && \
npm cache clear --force && \
apk del build-base python3 make npm && \
rm -rf /node-* /SHASUMS256.txt /tmp/* /root/.electron /root/.cache \
/sbin/apk /etc/apk /lib/apk /usr/share/apk /var/lib/apk \
/usr/share/man/* /usr/share/doc /root/.npm /root/.node-gyp /root/.config \
/usr/lib/node_modules/npm/man /usr/lib/node_modules/npm/doc /usr/lib/node_modules/npm/docs \
/usr/lib/node_modules/npm/html /usr/lib/node_modules/npm/scripts && \
{ rm -rf /root/.gnupg || true; }

EXPOSE 4002
EXPOSE 4003
EXPOSE 5002
EXPOSE 9090

CMD jsipfs daemon
COPY entrypoint.sh /entrypoint.sh

CMD ["catatonit", "/entrypoint.sh"]
20 changes: 20 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Proxy signals
_term() {
echo "Caught SIGTERM signal!"
pkill -TERM jsipfs
pkill -TERM -P1
exit 0
}

trap _term SIGTERM

export IPFS_PATH=$IPFS_PATH

if ! [[ -f "$IPFS_PATH" ]]; then
jsipfs init
fi

jsipfs daemon &
wait -n ${!}