docker-syncthing/Dockerfile
2020-11-02 07:43:40 -08:00

65 lines
1.6 KiB
Docker

FROM ghcr.io/linuxserver/baseimage-alpine:3.12 as buildstage
# build variables
ARG SYNCTHING_RELEASE
RUN \
echo "**** install build packages ****" && \
apk add --no-cache \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/community \
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \
curl \
g++ \
gcc \
git \
go \
tar
RUN \
echo "**** fetch source code ****" && \
if [ -z ${SYNCTHING_RELEASE+x} ]; then \
SYNCTHING_RELEASE=$(curl -sX GET "https://api.github.com/repos/syncthing/syncthing/releases/latest" \
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
fi && \
mkdir -p \
/tmp/sync && \
curl -o \
/tmp/syncthing-src.tar.gz -L \
"https://github.com/syncthing/syncthing/archive/${SYNCTHING_RELEASE}.tar.gz" && \
tar xf \
/tmp/syncthing-src.tar.gz -C \
/tmp/sync --strip-components=1 && \
echo "**** compile syncthing ****" && \
cd /tmp/sync && \
rm -f go.sum && \
go clean -modcache && \
CGO_ENABLED=0 go run build.go \
-no-upgrade \
-version=${SYNCTHING_RELEASE} \
build syncthing
############## runtime stage ##############
FROM ghcr.io/linuxserver/baseimage-alpine:3.12
# set version label
ARG BUILD_DATE
ARG VERSION
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
LABEL maintainer="thelamer"
# 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/sync/syncthing /usr/bin/
COPY root/ /
# ports and volumes
EXPOSE 8384 22000 21027/UDP
VOLUME /config