diff --git a/.gitignore b/.gitignore index 63054f6d6..354f7f4b8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ node-data *.tar.gz + +node_modules \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 088a6fd64..82526268d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -141,9 +141,13 @@ FROM ${BUILD_IMAGE} AS omnibus LABEL org.opencontainers.image.source https://github.com/terpnetwork/o-line RUN apt-get update && \ - apt-get install --no-install-recommends --assume-yes ca-certificates curl wget file unzip liblz4-tool gnupg2 jq pv && \ + apt-get install --no-install-recommends --assume-yes ca-certificates apt-transport-https curl wget file unzip liblz4-tool gnupg2 jq pv && \ apt-get clean +# install caddy +RUN echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" | tee -a /etc/apt/sources.list.d/caddy-fury.list +RUN apt-get update && apt-get install -y caddy + COPY --from=zstd_build /usr/local/bin/zstd /bin/ ARG PROJECT diff --git a/run.sh b/run.sh index a3854f4c0..a81e42f41 100755 --- a/run.sh +++ b/run.sh @@ -475,4 +475,22 @@ if [ -n "$SNAPSHOT_PATH" ]; then else echo "Running '$START_CMD'..." exec $START_CMD -fi \ No newline at end of file +fi + +# create systemctl for caddy +cat > /etc/systemd/system/caddy.service < /etc/caddy/Caddyfile <>${LOG_PATH} - - # move compress image to snapshot folder - log_this "Moving new snapshot to ${SNAP_PATH}" - mv ${HOME}/${CHAIN_ID}*tar ${SNAP_PATH} &>>${LOG_PATH} - - + # Serve snapshot via caddy + log_this "Serving new snapshot" + systemctl start caddy.service & + caddy_pid=$! + echo "$TIME: Snapshot available at http://localhost:80/terp_latest.tar.gz" fi - if [[ $SNAPSHOT_RETAIN != "0" || $SNAPSHOT_METADATA != "0" ]]; then - fi - snapshots=() - for line in "${s3Files[@]}"; do - createDate=`echo $line|awk {'print $1" "$2'}` - createDate=`date -d"$createDate" +%s` - fileName=`echo $line|awk '{$1=$2=$3=""; print $0}' | sed 's/^[ \t]*//'` - if [[ -n $SNAPSHOT_METADATA_URL && $SNAPSHOT_METADATA_URL != */ ]]; then - fileUrl="${SNAPSHOT_METADATA_URL}/${fileName}" - else - fileUrl="${SNAPSHOT_METADATA_URL}${fileName}" - fi - ## prune any snapshots if configured - if [ "$SNAPSHOT_RETAIN" != "0" ]; then - olderThan=`date -d"-$SNAPSHOT_RETAIN" +%s` - if [[ $createDate -lt $olderThan ]]; then - if [[ $fileName != "" ]]; then - echo "$TIME: Deleting snapshot $fileName" - fi - else - snapshots+=("$fileUrl") - fi - else - snapshots+=("$fileUrl") - fi - done; - - if [ "$SNAPSHOT_METADATA" != "0" ]; then - echo "$TIME: Uploading metadata" - snapshotJson="[]" - for url in ${snapshots[@]}; do - snapshotJson="$(echo $snapshotJson | jq ".+[\"$url\"]")" - done - else - fi - fi - fi - - echo "$TIME: Restarting server" + echo "$TIME: Restarting terpd" exec $SNAPSHOT_CMD & PID=$! sleep 1s @@ -118,3 +95,5 @@ while true; do fi fi done + +# todo: after n snapshots created prune k # of snapshots by saving to jackal storage provider \ No newline at end of file