1- FROM lsiobase/alpine:3.7
1+ FROM lsiobase/alpine:3.7 as buildstage
2+ # specifically using 3.7 alpine in buildstage
3+ # cgo bug in 1.10x go
4+ # runtime stage uses 3.8 alpine
25
3- # set version label
4- ARG BUILD_DATE
5- ARG VERSION
6- LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
7- LABEL maintainer="sparklyballs"
8-
9- # environment settings
6+ # build variables
107ARG SYNC_SRC="/tmp/syncthing"
118ARG SYNC_BUILD="$SYNC_SRC/src/github.com/syncthing/syncthing"
12- ENV HOME="/config"
139
1410RUN \
1511 echo "**** install build packages ****" && \
16- apk add --no-cache --virtual=build-dependencies \
12+ apk add --no-cache \
1713 curl \
1814 g++ \
1915 gcc \
2016 go \
21- tar && \
22- echo "**** compile syncthing ****" && \
17+ tar
18+
19+ RUN \
20+ echo "**** fetch source code ****" && \
2321 mkdir -p \
2422 "${SYNC_BUILD}" && \
25- export GOPATH="${SYNC_SRC}" && \
2623 SYNC_TAG=$(curl -sX GET "https://api.github.com/repos/syncthing/syncthing/releases/latest" \
2724 | awk '/tag_name/{print $4;exit}' FS='[""]' ) && \
2825 curl -o \
@@ -31,27 +28,41 @@ RUN \
3128 tar xf \
3229 /tmp/syncthing-src.tar.gz -C \
3330 "${SYNC_BUILD}" --strip-components=1 && \
31+ echo "**** compile syncthing ****" && \
3432 cd "${SYNC_BUILD}" && \
33+ export GOPATH="${SYNC_SRC}" && \
3534 go run build.go -no-upgrade -version=${SYNC_TAG} && \
36- echo "**** install syncthing ****" && \
37- install -d -o abc -g abc \
38- /var/lib/syncthing && \
35+ echo "**** install syncthing to tmp folder ****" && \
36+ mkdir -p \
37+ /tmp/bin && \
3938 install -D -m755 \
4039 $SYNC_BUILD/bin/syncthing \
41- /usr /bin/syncthing && \
40+ /tmp /bin/syncthing && \
4241 for i in $(ls $SYNC_BUILD/bin); \
4342 do if ! [ "$i" = "syncthing" ]; \
44- then install -Dm 755 $SYNC_BUILD/bin/$i /usr /bin/$i ; \
43+ then install -Dm 755 $SYNC_BUILD/bin/$i /tmp /bin/$i ; \
4544 fi; \
46- done && \
47- export GOPATH="" && \
48- echo "**** cleanup ****" && \
49- apk del --purge \
50- build-dependencies && \
51- rm -rf \
52- /tmp/*
53-
54- # add local files
45+ done
46+
47+ # ############# runtime stage ##############
48+ FROM lsiobase/alpine:3.8
49+
50+ # set version label
51+ ARG BUILD_DATE
52+ ARG VERSION
53+ LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
54+ LABEL maintainer="sparklyballs"
55+
56+ # environment settings
57+ ENV HOME="/config"
58+
59+ RUN \
60+ echo "**** create var lib folder ****" && \
61+ install -d -o abc -g abc \
62+ /var/lib/syncthing
63+
64+ # copy files from build stage and local files
65+ COPY --from=buildstage /tmp/bin/ /usr/bin/
5566COPY root/ /
5667
5768# ports and volumes
0 commit comments