From d5cbd2a7ed5509e073cb5fb0494307c8e9ba91b8 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Mon, 30 Jul 2018 22:52:46 +0100 Subject: [PATCH] bump alpine 3.8 and use buildstage type build --- Dockerfile | 63 ++++++++++++++++++++++++++++++++---------------------- README.md | 1 + 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index acfb8a1..bbda192 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,28 +1,25 @@ -FROM lsiobase/alpine:3.7 +FROM lsiobase/alpine:3.7 as buildstage +# specifically using 3.7 alpine in buildstage +# cgo bug in 1.10x go +# runtime stage uses 3.8 alpine -# set version label -ARG BUILD_DATE -ARG VERSION -LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" -LABEL maintainer="sparklyballs" - -# environment settings +# build variables ARG SYNC_SRC="/tmp/syncthing" ARG SYNC_BUILD="$SYNC_SRC/src/github.com/syncthing/syncthing" -ENV HOME="/config" RUN \ echo "**** install build packages ****" && \ - apk add --no-cache --virtual=build-dependencies \ + apk add --no-cache \ curl \ g++ \ gcc \ go \ - tar && \ - echo "**** compile syncthing ****" && \ + tar + +RUN \ +echo "**** fetch source code ****" && \ mkdir -p \ "${SYNC_BUILD}" && \ - export GOPATH="${SYNC_SRC}" && \ SYNC_TAG=$(curl -sX GET "https://api.github.com/repos/syncthing/syncthing/releases/latest" \ | awk '/tag_name/{print $4;exit}' FS='[""]') && \ curl -o \ @@ -31,27 +28,41 @@ RUN \ tar xf \ /tmp/syncthing-src.tar.gz -C \ "${SYNC_BUILD}" --strip-components=1 && \ + echo "**** compile syncthing ****" && \ cd "${SYNC_BUILD}" && \ + export GOPATH="${SYNC_SRC}" && \ go run build.go -no-upgrade -version=${SYNC_TAG} && \ - echo "**** install syncthing ****" && \ - install -d -o abc -g abc \ - /var/lib/syncthing && \ + echo "**** install syncthing to tmp folder ****" && \ + mkdir -p \ + /tmp/bin && \ install -D -m755 \ $SYNC_BUILD/bin/syncthing \ - /usr/bin/syncthing && \ + /tmp/bin/syncthing && \ for i in $(ls $SYNC_BUILD/bin); \ do if ! [ "$i" = "syncthing" ]; \ - then install -Dm 755 $SYNC_BUILD/bin/$i /usr/bin/$i ; \ + then install -Dm 755 $SYNC_BUILD/bin/$i /tmp/bin/$i ; \ fi; \ - done && \ - export GOPATH="" && \ - echo "**** cleanup ****" && \ - apk del --purge \ - build-dependencies && \ - rm -rf \ - /tmp/* + done -# add local files +############## runtime stage ############## +FROM lsiobase/alpine:3.8 + +# set version label +ARG BUILD_DATE +ARG VERSION +LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}" +LABEL maintainer="sparklyballs" + +# environment settings +ENV HOME="/config" + +RUN \ + echo "**** create var lib folder ****" && \ + install -d -o abc -g abc \ + /var/lib/syncthing + +# copy files from build stage and local files +COPY --from=buildstage /tmp/bin/ /usr/bin/ COPY root/ / # ports and volumes diff --git a/README.md b/README.md index 5e23480..cb3d6b4 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ You can find some of the best documentation available on the web at [docs.syncth ## Versions ++ **30.07.17:** Rebase to alpine 3.8 and use buildstage. + **13.12.17:** Rebase to alpine 3.7. + **25.10.17:** Add env for manual setting of umask. + **29.07.17:** Simplify build structure as symlinks failing on > 0.14.32