diff --git a/Dockerfile-alpine b/Dockerfile-alpine new file mode 100644 index 00000000..f862325f --- /dev/null +++ b/Dockerfile-alpine @@ -0,0 +1,21 @@ +# -*-Dockerfile-*- +FROM golang:alpine +RUN apk add alpine-sdk bash llvm5 gnupg xz jq curl-dev sqlite-dev binutils-gold +ARG LDC_VERSION=1.13.0 +ENV LDC_VERSION=${LDC_VERSION} +RUN curl -fsSL "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION}/ldc2-${LDC_VERSION}-alpine-linux-x86_64.tar.xz" |\ + tar xJf - -C / && \ + mv "/ldc2-${LDC_VERSION}-alpine-linux-x86_64" "/ldc" +ENV PATH="/ldc/bin:${PATH}" \ + LD_LIBRARY_PATH="/ldc/lib:/usr/lib:/lib:${LD_LIBRARY_PATH}" \ + LIBRARY_PATH="/ldc/lib:/usr/lib:/lib:${LD_LIBRARY_PATH}" +RUN go get github.com/tianon/gosu +COPY . /usr/src/onedrive +RUN make -C /usr/src/onedrive install.noservice DC=ldmd2 + +FROM alpine +ENTRYPOINT ["/entrypoint.sh"] +RUN apk add --no-cache bash libcurl libgcc shadow sqlite-libs && \ + mkdir -p /onedrive/conf /onedrive/data +COPY entrypoint.sh / +COPY --from=0 /go/bin/gosu /usr/local/bin/onedrive /usr/local/bin/ diff --git a/Dockerfile-stretch b/Dockerfile-stretch new file mode 100644 index 00000000..d6509136 --- /dev/null +++ b/Dockerfile-stretch @@ -0,0 +1,18 @@ +# -*-Dockerfile-*- +FROM debian:stretch +RUN apt update && \ + apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev +RUN curl -fsS -o install.sh https://dlang.org/install.sh && \ + bash install.sh dmd +COPY . /usr/src/onedrive +RUN . "$(bash install.sh -a)" && \ + make -C /usr/src/onedrive install.noservice + +FROM debian:stretch-slim +ENTRYPOINT ["/entrypoint.sh"] +RUN apt update && \ + apt install -y gosu libcurl3 libsqlite3-0 && \ + rm -rf /var/*/apt && \ + mkdir -p /onedrive/conf /onedrive/data +COPY entrypoint.sh / +COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/ diff --git a/README.docker.md b/README.docker.md index e1a53dfd..7c7377cd 100644 --- a/README.docker.md +++ b/README.docker.md @@ -123,3 +123,17 @@ git clone https://github.com/abraunegg/onedrive cd onedrive docker build . -t local-onedrive ``` + +There are alternate, smaller images available by building +Dockerfile-stretch or Dockerfile-alpine. These [multi-stage builder +pattern](https://docs.docker.com/develop/develop-images/multistage-build/) +Dockerfiles require Docker version at least 17.05. + +``` bash +docker build . -t local-ondrive-stretch -f Dockerfile-stretch +``` +or + +``` bash +docker build . -t local-ondrive-alpine -f Dockerfile-alpine +``` diff --git a/src/progress.d b/src/progress.d index fc0da509..d8b33e04 100644 --- a/src/progress.d +++ b/src/progress.d @@ -22,12 +22,14 @@ class Progress size_t getTerminalWidth() { - size_t column; - winsize ws; - if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) { - column = ws.ws_col; + size_t column = default_width; + version (CRuntime_Musl) { + } else { + winsize ws; + if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 0) { + column = ws.ws_col; + } } - if(column == 0) column = default_width; return column; }