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 all commits
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
35 changes: 16 additions & 19 deletions Dockerfile.latest
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
FROM node:16-alpine
FROM alpine:3.17

ENV IPFS_VERSION=latest
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 && \
apk add --no-cache --virtual .build-deps npm git build-base python3 && \
npm install -g --build-from-source ipfs@"$IPFS_VERSION" && \
npm cache clear --force && \
apk del .build-deps && \
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", "-g", "/entrypoint.sh"]
35 changes: 16 additions & 19 deletions Dockerfile.next
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
FROM node:16-alpine
FROM alpine:3.17

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 && \
apk add --no-cache --virtual .build-deps npm git build-base python3 && \
npm install -g --build-from-source ipfs@"$IPFS_VERSION" && \
npm cache clear --force && \
apk del .build-deps && \
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", "-g", "/entrypoint.sh"]
12 changes: 12 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
if [[ -d "$IPFS_PATH/repo.lock" ]]; then
echo "Automatically removing a stale repo lock."
rm -rf $IPFS_PATH/repo.lock
fi

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

jsipfs daemon & \
wait -n