aboutsummaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorshibinbin <shibinbin@megvii.com>2020-10-28 11:36:42 +0800
committershibinbin <shibinbin@megvii.com>2020-10-28 11:36:42 +0800
commit7cc07655d493d11c967cfa978ddc5181d4b6b861 (patch)
tree5ae5bcf7ccc3cee3c55372674753d7c1ca48dff9 /docker
parent29a4c3944eeb07434060df52dfb1d3cf4c59dc91 (diff)
parent53c3aad87528d57343afc5fdb3fb5107544af0fc (diff)
downloadseaweedfs-7cc07655d493d11c967cfa978ddc5181d4b6b861.tar.xz
seaweedfs-7cc07655d493d11c967cfa978ddc5181d4b6b861.zip
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'docker')
-rw-r--r--docker/Dockerfile26
-rw-r--r--docker/Dockerfile.go_build4
-rw-r--r--docker/Dockerfile.go_build_large37
-rw-r--r--docker/README.md10
-rwxr-xr-xdocker/entrypoint.sh38
-rw-r--r--docker/local-cluster-compose.yml8
6 files changed, 100 insertions, 23 deletions
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 38117a3dc..7146b91c7 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,15 +1,19 @@
-FROM frolvlad/alpine-glibc
+FROM alpine
-# Supercronic install settings
-ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.8/supercronic-linux-amd64 \
- SUPERCRONIC=supercronic-linux-amd64 \
- SUPERCRONIC_SHA1SUM=be43e64c45acd6ec4fce5831e03759c89676a0ea
-
-# Install SeaweedFS and Supercronic ( for cron job mode )
-# Tried to use curl only (curl -o /tmp/linux_amd64.tar.gz ...), however it turned out that the following tar command failed with "gzip: stdin: not in gzip format"
-RUN apk add --no-cache --virtual build-dependencies --update wget curl ca-certificates && \
- wget -P /tmp https://github.com/$(curl -s -L https://github.com/chrislusf/seaweedfs/releases/latest | egrep -o 'chrislusf/seaweedfs/releases/download/.*/linux_amd64.tar.gz') && \
- tar -C /usr/bin/ -xzvf /tmp/linux_amd64.tar.gz && \
+RUN \
+ ARCH=$(if [ $(uname -m) == "x86_64" ] && [ $(getconf LONG_BIT) == "64" ]; then echo "amd64"; \
+ elif [ $(uname -m) == "x86_64" ] && [ $(getconf LONG_BIT) == "32" ]; then echo "386"; \
+ elif [ $(uname -m) == "aarch64" ]; then echo "arm64"; \
+ elif [ $(uname -m) == "armv7l" ]; then echo "arm"; \
+ elif [ $(uname -m) == "armv6l" ]; then echo "arm"; fi;) && \
+ echo "Building for $ARCH" 1>&2 && \
+ SUPERCRONIC_SHA1SUM=$(echo $ARCH | sed 's/386/e0126b0102b9f388ecd55714358e3ad60d0cebdb/g' | sed 's/amd64/5ddf8ea26b56d4a7ff6faecdd8966610d5cb9d85/g' | sed 's/arm64/e2714c43e7781bf1579c85aa61259245f56dbba1/g' | sed 's/arm/47481c3341bc3a1ae91a728e0cc63c8e6d3791ad/g') && \
+ SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.1.9/supercronic-linux-$ARCH && \
+ SUPERCRONIC=supercronic-linux-$ARCH && \
+ # Install SeaweedFS and Supercronic ( for cron job mode )
+ apk add --no-cache --virtual build-dependencies --update wget curl ca-certificates && \
+ wget -P /tmp https://github.com/$(curl -s -L https://github.com/chrislusf/seaweedfs/releases/latest | egrep -o "chrislusf/seaweedfs/releases/download/.*/linux_$ARCH.tar.gz") && \
+ tar -C /usr/bin/ -xzvf /tmp/linux_$ARCH.tar.gz && \
curl -fsSLO "$SUPERCRONIC_URL" && \
echo "${SUPERCRONIC_SHA1SUM} ${SUPERCRONIC}" | sha1sum -c - && \
chmod +x "$SUPERCRONIC" && \
diff --git a/docker/Dockerfile.go_build b/docker/Dockerfile.go_build
index 306ce3aa1..29b9a85d8 100644
--- a/docker/Dockerfile.go_build
+++ b/docker/Dockerfile.go_build
@@ -2,7 +2,9 @@ FROM frolvlad/alpine-glibc as builder
RUN apk add git go g++
RUN mkdir -p /go/src/github.com/chrislusf/
RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
-RUN cd /go/src/github.com/chrislusf/seaweedfs/weed && go install
+RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
+ && export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
+ && go install -ldflags "${LDFLAGS}"
FROM alpine AS final
LABEL author="Chris Lu"
diff --git a/docker/Dockerfile.go_build_large b/docker/Dockerfile.go_build_large
new file mode 100644
index 000000000..fa22aeade
--- /dev/null
+++ b/docker/Dockerfile.go_build_large
@@ -0,0 +1,37 @@
+FROM frolvlad/alpine-glibc as builder
+RUN apk add git go g++
+RUN mkdir -p /go/src/github.com/chrislusf/
+RUN git clone https://github.com/chrislusf/seaweedfs /go/src/github.com/chrislusf/seaweedfs
+RUN cd /go/src/github.com/chrislusf/seaweedfs/weed \
+ && export LDFLAGS="-X github.com/chrislusf/seaweedfs/weed/util.COMMIT=$(git rev-parse --short HEAD)" \
+ && go install -tags 5BytesOffset -ldflags "${LDFLAGS}"
+
+FROM alpine AS final
+LABEL author="Chris Lu"
+COPY --from=builder /root/go/bin/weed /usr/bin/
+RUN mkdir -p /etc/seaweedfs
+COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/filer.toml /etc/seaweedfs/filer.toml
+COPY --from=builder /go/src/github.com/chrislusf/seaweedfs/docker/entrypoint.sh /entrypoint.sh
+
+# volume server gprc port
+EXPOSE 18080
+# volume server http port
+EXPOSE 8080
+# filer server gprc port
+EXPOSE 18888
+# filer server http port
+EXPOSE 8888
+# master server shared gprc port
+EXPOSE 19333
+# master server shared http port
+EXPOSE 9333
+# s3 server http port
+EXPOSE 8333
+
+RUN mkdir -p /data/filerldb2
+
+VOLUME /data
+
+RUN chmod +x /entrypoint.sh
+
+ENTRYPOINT ["/entrypoint.sh"]
diff --git a/docker/README.md b/docker/README.md
index 65241b517..d6e1f4928 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -27,3 +27,13 @@ docker-compose -f seaweedfs-dev-compose.yml -p seaweedfs up
cd $GOPATH/src/github.com/chrislusf/seaweedfs/docker
make
```
+
+## Build and push a multiarch build
+
+Make sure that `docker buildx` is supported (might be an experimental docker feature)
+```bash
+BUILDER=$(docker buildx create --driver docker-container --use)
+docker buildx build --pull --push --platform linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 . -t chrislusf/seaweedfs
+docker buildx stop $BUILDER
+```
+
diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh
index 05db7a672..5a858d993 100755
--- a/docker/entrypoint.sh
+++ b/docker/entrypoint.sh
@@ -1,36 +1,60 @@
#!/bin/sh
+isArgPassed() {
+ arg="$1"
+ argWithEqualSign="$1="
+ shift
+ while [ $# -gt 0 ]; do
+ passedArg="$1"
+ shift
+ case $passedArg in
+ $arg)
+ return 0
+ ;;
+ $argWithEqualSign*)
+ return 0
+ ;;
+ esac
+ done
+ return 1
+}
+
case "$1" in
'master')
ARGS="-mdir=/data -volumePreallocate -volumeSizeLimitMB=1024"
- exec /usr/bin/weed $@ $ARGS
+ shift
+ exec /usr/bin/weed master $ARGS $@
;;
'volume')
ARGS="-dir=/data -max=0"
- if [[ $@ == *"-max="* ]]; then
+ if isArgPassed "-max" "$@"; then
ARGS="-dir=/data"
fi
- exec /usr/bin/weed $@ $ARGS
+ shift
+ exec /usr/bin/weed volume $ARGS $@
;;
'server')
ARGS="-dir=/data -volume.max=0 -master.volumePreallocate -master.volumeSizeLimitMB=1024"
- if [[ $@ == *"-volume.max="* ]]; then
+ if isArgPassed "-volume.max" "$@"; then
ARGS="-dir=/data -master.volumePreallocate -master.volumeSizeLimitMB=1024"
fi
- exec /usr/bin/weed $@ $ARGS
+ shift
+ exec /usr/bin/weed server $ARGS $@
;;
'filer')
ARGS=""
- exec /usr/bin/weed $@ $ARGS
+ shift
+ exec /usr/bin/weed filer $ARGS $@
;;
's3')
ARGS="-domainName=$S3_DOMAIN_NAME -key.file=$S3_KEY_FILE -cert.file=$S3_CERT_FILE"
- exec /usr/bin/weed $@ $ARGS
+ shift
+ exec /usr/bin/weed s3 $ARGS $@
;;
'cronjob')
diff --git a/docker/local-cluster-compose.yml b/docker/local-cluster-compose.yml
index a1ac824e7..bf12c4639 100644
--- a/docker/local-cluster-compose.yml
+++ b/docker/local-cluster-compose.yml
@@ -6,25 +6,25 @@ services:
ports:
- 9333:9333
- 19333:19333
- command: "master -ip=master0 -port=9333 -peers=master0:9333,master1:9334,master2:9335"
+ command: "master -ip=master0 -port=9333 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m1"
master1:
image: chrislusf/seaweedfs:local
ports:
- 9334:9334
- 19334:19334
- command: "master -ip=master1 -port=9334 -peers=master0:9333,master1:9334,master2:9335"
+ command: "master -ip=master1 -port=9334 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m2"
master2:
image: chrislusf/seaweedfs:local
ports:
- 9335:9335
- 19335:19335
- command: "master -ip=master2 -port=9335 -peers=master0:9333,master1:9334,master2:9335"
+ command: "master -ip=master2 -port=9335 -peers=master0:9333,master1:9334,master2:9335 -mdir=/data/m3"
volume:
image: chrislusf/seaweedfs:local
ports:
- 8080:8080
- 18080:18080
- command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume'
+ command: 'volume -mserver="master0:9333,master1:9334,master2:9335" -port=8080 -ip=volume -publicUrl=localhost:8080'
depends_on:
- master0
- master1