bump alpine 3.8 and use buildstage type build

This commit is contained in:
sparklyballs 2018-07-30 22:52:46 +01:00
parent 79e0dab58a
commit d5cbd2a7ed
2 changed files with 38 additions and 26 deletions

View File

@ -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

View File

@ -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