File tree Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Expand file tree Collapse file tree 2 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ ARG VERSION
44
55RUN apk --update add gcc git curl alpine-sdk libc6-compat ca-certificates sqlite \
66 && curl -SsL https://github.com/segmentio/chamber/releases/download/v2.13.2/chamber-v2.13.2-linux-amd64 -o /bin/chamber \
7- && chmod +x /bin/chamber
7+ && curl -sL https://github.com/peak/s5cmd/releases/download/v2.1.0/s5cmd_2.1.0_Linux-64bit.tar.gz -o s5cmd.gz && tar -xzf s5cmd.gz -C /bin \
8+ && chmod +x /bin/chamber \
9+ && chmod +x /bin/s5cmd
10+
811
912COPY . /go/src/${SRC}
1013WORKDIR /go/src/${SRC}
@@ -15,11 +18,11 @@ RUN CGO_ENABLED=1 go install -ldflags="-X github.com/segmentio/ctlstore/pkg/vers
1518RUN CGO_ENABLED=1 go install -ldflags="-X github.com/segmentio/ctlstore/pkg/version.version=$VERSION" ${SRC}/pkg/cmd/ctlstore-cli \
1619 && cp ${GOPATH}/bin/ctlstore-cli /usr/local/bin
1720
18- RUN apk del gcc git curl alpine-sdk libc6-compat
19-
2021FROM alpine
21- RUN apk --no-cache add sqlite
22+ RUN apk --no-cache add sqlite pigz
2223
24+ COPY --from=0 /go/src/github.com/segmentio/ctlstore/scripts/download.sh .
2325COPY --from=0 /bin/chamber /bin/chamber
26+ COPY --from=0 /bin/s5cmd /bin/s5cmd
2427COPY --from=0 /usr/local/bin/ctlstore /usr/local/bin/
2528COPY --from=0 /usr/local/bin/ctlstore-cli /usr/local/bin/
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env sh
2+
3+ set -eo pipefail
4+
5+ CTLSTORE_BOOTSTRAP_URL=$1
6+ CONCURRENCY=${2:- 20}
7+ STATS_IP=$3
8+ STATS_PORT=${4:- 8125}
9+
10+ TAGS=" downloaded:false"
11+ START=$( date +%s)
12+ END=$( date +%s)
13+ if [ ! -f /var/spool/ctlstore/ldb.db ]; then
14+ # busybox does not support sub-second resolution
15+ START=$( date +%s)
16+
17+ mkdir -p /var/spool/ctlstore
18+ cd /var/spool/ctlstore
19+ s5cmd -r 0 --log debug cp --concurrency $CONCURRENCY $CTLSTORE_BOOTSTRAP_URL .
20+
21+ TAGS=" downloaded:true"
22+ if [[ ${CTLSTORE_BOOTSTRAP_URL: -2} == gz ]]; then
23+ echo " Decompressing"
24+ pigz -d snapshot.db.gz
25+ TAGS=" $TAGS ,compressed:true"
26+ fi
27+
28+ TAGS=" $TAGS ,concurrency:$CONCURRENCY "
29+
30+ mv snapshot.db ldb.db
31+ END=$( date +%s)
32+ echo " ldb.db ready in $(( $END - $START )) seconds"
33+ else
34+ echo " Snapshot already present"
35+ fi
36+
37+ if [ ! -z " $STATS_IP " ]; then
38+ echo -n " ctlstore.reflector.init_snapshot_download_time:$(( $END - $START )) |h|#$TAGS " | nc -u -w1 $NODE_IP $STATS_PORT
39+ fi
You can’t perform that action at this time.
0 commit comments