sjqzhang/go-fastdfs

基于文档中Dockerfile构建镜像无法正常运行

lxh-015 opened this issue · 1 comments

使用Dockerfile

FROM registry.cn-hangzhou.aliyuncs.com/prince/alpine-golang:1.18 as builder
MAINTAINER s_jqzhang <s_jqzhang@163.com>
ARG VERSION=1.1.7
RUN set -xe; \
	apk update; \
	apk add --no-cache --virtual .build-deps \
	git; \
	mkdir -p /root/repo ; cd /root/repo ; \
	git clone https://github.com/sjqzhang/go-fastdfs ; \
	cd go-fastdfs; mv vendor src ; mv src .. ; cd .. ; mv go-fastdfs src/github.com/sjqzhang/ ; export GOPATH=/root/repo ; cd  src/github.com/sjqzhang/go-fastdfs ; \
	 export GO111MODULE="off"; \
	CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o fileserver; \
	ls -lh .;
FROM registry.cn-hangzhou.aliyuncs.com/prince/alpine-bash

COPY --from=builder /root/repo/src/github.com/sjqzhang/go-fastdfs/fileserver /

ENV INSTALL_DIR /usr/local/go-fastdfs

ENV PATH $PATH:$INSTALL_DIR/

ENV GO_FASTDFS_DIR $INSTALL_DIR/data

RUN set -xe; \
	mkdir -p $GO_FASTDFS_DIR; \
	mkdir -p $GO_FASTDFS_DIR/conf; \
	mkdir -p $GO_FASTDFS_DIR/data; \
	mkdir -p $GO_FASTDFS_DIR/files; \
	mkdir -p $GO_FASTDFS_DIR/log; \
	mkdir -p $INSTALL_DIR; \
	mv /fileserver $INSTALL_DIR/; \
	chmod +x $INSTALL_DIR/fileserver;

WORKDIR $INSTALL_DIR

VOLUME $GO_FASTDFS_DIR

CMD ["fileserver", "server" , "${OPTS}"]

错误内容

4387674967e5:~/repo/src/github.com/sjqzhang/go-fastdfs# ./fileserver server
+ ./fileserver server
unexpected fault address 0x0
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x80 addr=0x0 pc=0x466e3f]

goroutine 1 [running]:
runtime.throw({0xa1e53d?, 0x0?})
	/usr/local/go/src/runtime/panic.go:992 +0x71 fp=0xc0000db478 sp=0xc0000db448 pc=0x437751
runtime.sigpanic()
	/usr/local/go/src/runtime/signal_unix.go:825 +0x2ec fp=0xc0000db4c8 sp=0xc0000db478 pc=0x44d7cc
aeshashbody()
	/usr/local/go/src/runtime/asm_amd64.s:1343 +0x39f fp=0xc0000db4d0 sp=0xc0000db4c8 pc=0x466e3f
runtime.mapiternext(0xc0000aa640)
	/usr/local/go/src/runtime/map.go:934 +0x2cb fp=0xc0000db540 sp=0xc0000db4d0 pc=0x41184b
runtime.mapiterinit(0xc000058c00?, 0xc00018ef70?, 0x0?)
	/usr/local/go/src/runtime/map.go:861 +0x228 fp=0xc0000db560 sp=0xc0000db540 pc=0x411528
reflect.mapiterinit(0x410e3d?, 0x976f80?, 0xc00018ef78?)
	/usr/local/go/src/runtime/map.go:1373 +0x19 fp=0xc0000db588 sp=0xc0000db560 pc=0x463939
github.com/modern-go/reflect2.(*UnsafeMapType).UnsafeIterate(...)
	/root/repo/src/github.com/modern-go/reflect2/unsafe_map.go:112
github.com/json-iterator/go.(*sortKeysMapEncoder).Encode(0xc0000c3770, 0xc000096238, 0xc000090c00)
	/root/repo/src/github.com/json-iterator/go/reflect_map.go:291 +0x225 fp=0xc0000db6f8 sp=0xc0000db588 pc=0x82d5c5
github.com/json-iterator/go.(*onePtrEncoder).Encode(0xc00001f400, 0xc0000c3560, 0xc0000aa640?)
	/root/repo/src/github.com/json-iterator/go/reflect.go:219 +0x82 fp=0xc0000db730 sp=0xc0000db6f8 pc=0x8258c2
github.com/json-iterator/go.(*Stream).WriteVal(0xc000090c00, {0x985a00, 0xc0000c3560})
	/root/repo/src/github.com/json-iterator/go/reflect.go:98 +0x158 fp=0xc0000db7a0 sp=0xc0000db730 pc=0x824bd8
github.com/json-iterator/go.(*frozenConfig).Marshal(0xc000120fa0, {0x985a00, 0xc0000c3560})
	/root/repo/src/github.com/json-iterator/go/config.go:299 +0xc9 fp=0xc0000db838 sp=0xc0000db7a0 pc=0x81bd09
github.com/sjqzhang/go-fastdfs/server.(*Server).SaveStat.func1()
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/fileserver.go:592 +0x156 fp=0xc0000db8a0 sp=0xc0000db838 pc=0x8f8616
github.com/sjqzhang/go-fastdfs/server.(*Server).SaveStat(0xc0000329a0?)
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/fileserver.go:601 +0x33 fp=0xc0000db8c0 sp=0xc0000db8a0 pc=0x8f8493
github.com/sjqzhang/go-fastdfs/server.(*Server).RepairStatByDate(0xc0001922d0, {0xc000037fe0, 0x8})
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/http_repair.go:149 +0x425 fp=0xc0000dba28 sp=0xc0000db8c0 pc=0x90d0a5
github.com/sjqzhang/go-fastdfs/server.(*Server).FormatStatInfo(0xc0001922d0)
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/fileserver.go:1275 +0x89 fp=0xc0000dbb00 sp=0xc0000dba28 pc=0x8fc749
github.com/sjqzhang/go-fastdfs/server.(*Server).initComponent(0xc0001922d0, 0x0)
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/init.go:295 +0x3a5 fp=0xc0000dbc00 sp=0xc0000dbb00 pc=0x9179c5
github.com/sjqzhang/go-fastdfs/server.InitServer()
	/root/repo/src/github.com/sjqzhang/go-fastdfs/server/server.go:124 +0x10dd fp=0xc0000dbd78 sp=0xc0000dbc00 pc=0x91b19d
github.com/sjqzhang/go-fastdfs/cmd/server.main()
	/root/repo/src/github.com/sjqzhang/go-fastdfs/cmd/server/cmd.go:19 +0x19 fp=0xc0000dbd90 sp=0xc0000dbd78 pc=0x91ef79
github.com/sjqzhang/go-fastdfs/cmd/server.glob..func1(0xe5df00?, {0xa1e041?, 0x0?, 0x0?})
	/root/repo/src/github.com/sjqzhang/go-fastdfs/cmd/server/cmd.go:14 +0x17 fp=0xc0000dbda0 sp=0xc0000dbd90 pc=0x91ef37
github.com/spf13/cobra.(*Command).execute(0xe5df00, {0xe95230, 0x0, 0x0})
	/root/repo/src/github.com/spf13/cobra/command.go:856 +0x663 fp=0xc0000dbe78 sp=0xc0000dbda0 pc=0x7de7e3
github.com/spf13/cobra.(*Command).ExecuteC(0xc0001a9680)
	/root/repo/src/github.com/spf13/cobra/command.go:960 +0x39c fp=0xc0000dbf30 sp=0xc0000dbe78 pc=0x7deddc
github.com/spf13/cobra.(*Command).Execute(...)
	/root/repo/src/github.com/spf13/cobra/command.go:897
main.main()
	/root/repo/src/github.com/sjqzhang/go-fastdfs/main.go:31 +0x165 fp=0xc0000dbf80 sp=0xc0000dbf30 pc=0x91f2a5
runtime.main()
	/usr/local/go/src/runtime/proc.go:250 +0x212 fp=0xc0000dbfe0 sp=0xc0000dbf80 pc=0x439f32
runtime.goexit()
	/usr/local/go/src/runtime/asm_amd64.s:1571 +0x1 fp=0xc0000dbfe8 sp=0xc0000dbfe0 pc=0x469a41

goroutine 4 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc00014acd0, 0x0)
	/usr/local/go/src/runtime/sema.go:513 +0x13d
sync.(*Cond).Wait(0x0?)
	/usr/local/go/src/sync/cond.go:56 +0x8c
github.com/sjqzhang/seelog.(*asyncLoopLogger).processItem(0xc000192000)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:50 +0xa5
github.com/sjqzhang/seelog.(*asyncLoopLogger).processQueue(0xc000192000)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:63 +0x35
created by github.com/sjqzhang/seelog.NewAsyncLoopLogger
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:40 +0xca

goroutine 5 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc00014ae50, 0x0)
	/usr/local/go/src/runtime/sema.go:513 +0x13d
sync.(*Cond).Wait(0x0?)
	/usr/local/go/src/sync/cond.go:56 +0x8c
github.com/sjqzhang/seelog.(*asyncLoopLogger).processItem(0xc000192120)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:50 +0xa5
github.com/sjqzhang/seelog.(*asyncLoopLogger).processQueue(0xc000192120)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:63 +0x35
created by github.com/sjqzhang/seelog.NewAsyncLoopLogger
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynclooplogger.go:40 +0xca

goroutine 8 [select]:
github.com/syndtr/goleveldb/leveldb/util.(*BufferPool).drain(0xc0001862a0)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:206 +0xc7
created by github.com/syndtr/goleveldb/leveldb/util.NewBufferPool
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:237 +0x18c

goroutine 20 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).compactionError(0xc000194820)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:90 +0x158
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:142 +0x4ea

goroutine 21 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain(0xc000194820)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_state.go:101 +0xa8
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:143 +0x52a

goroutine 22 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0xc000194820)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:825 +0x657
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:149 +0x598

goroutine 23 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction(0xc000194820)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:762 +0x113
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:150 +0x5d6

goroutine 24 [select]:
github.com/syndtr/goleveldb/leveldb/util.(*BufferPool).drain(0xc000186380)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:206 +0xc7
created by github.com/syndtr/goleveldb/leveldb/util.NewBufferPool
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/util/buffer_pool.go:237 +0x18c

goroutine 25 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).compactionError(0xc0001951e0)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:90 +0x158
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:142 +0x4ea

goroutine 26 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain(0xc0001951e0)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_state.go:101 +0xa8
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:143 +0x52a

goroutine 27 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).tCompaction(0xc0001951e0)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:825 +0x657
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:149 +0x598

goroutine 28 [select]:
github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction(0xc0001951e0)
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go:762 +0x113
created by github.com/syndtr/goleveldb/leveldb.openDB
	/root/repo/src/github.com/syndtr/goleveldb/leveldb/db.go:150 +0x5d6

goroutine 9 [chan receive]:
github.com/sjqzhang/seelog.(*bufferedWriter).flushPeriodically(0xc00007fd40)
	/root/repo/src/github.com/sjqzhang/seelog/writers_bufferedwriter.go:153 +0x47
created by github.com/sjqzhang/seelog.NewBufferedWriter
	/root/repo/src/github.com/sjqzhang/seelog/writers_bufferedwriter.go:76 +0x1ef

goroutine 10 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc00014b4d0, 0x1)
	/usr/local/go/src/runtime/sema.go:513 +0x13d
sync.(*Cond).Wait(0x3e8?)
	/usr/local/go/src/sync/cond.go:56 +0x8c
github.com/sjqzhang/seelog.(*asyncTimerLogger).processItem(0xc0001923f0)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:61 +0xa5
github.com/sjqzhang/seelog.(*asyncTimerLogger).processQueue(0xc0001923f0)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:74 +0x53
created by github.com/sjqzhang/seelog.NewAsyncTimerLogger
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:51 +0xe5

goroutine 11 [chan receive]:
github.com/sjqzhang/seelog.(*bufferedWriter).flushPeriodically(0xc000189fb0)
	/root/repo/src/github.com/sjqzhang/seelog/writers_bufferedwriter.go:153 +0x47
created by github.com/sjqzhang/seelog.NewBufferedWriter
	/root/repo/src/github.com/sjqzhang/seelog/writers_bufferedwriter.go:76 +0x1ef

goroutine 12 [sync.Cond.Wait]:
sync.runtime_notifyListWait(0xc00014bd50, 0x0)
	/usr/local/go/src/runtime/sema.go:513 +0x13d
sync.(*Cond).Wait(0x0?)
	/usr/local/go/src/sync/cond.go:56 +0x8c
github.com/sjqzhang/seelog.(*asyncTimerLogger).processItem(0xc0001925a0)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:61 +0xa5
github.com/sjqzhang/seelog.(*asyncTimerLogger).processQueue(0xc0001925a0)
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:74 +0x53
created by github.com/sjqzhang/seelog.NewAsyncTimerLogger
	/root/repo/src/github.com/sjqzhang/seelog/behavior_asynctimerlogger.go:51 +0xe5

golang版本由现在的go1.18->go1.17问题已修复。