mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-15 20:25:18 +02:00
Add smaller footprint Docker container builds using Alpine and Debian Stretch (#369)
* Add additional Docker container builds utilising a smaller OS footprint * Resolve compiling with LDC on Alpine as musl lacks some standard interfaces
This commit is contained in:
parent
51615bff0b
commit
460596dd36
21
Dockerfile-alpine
Normal file
21
Dockerfile-alpine
Normal file
|
@ -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/
|
18
Dockerfile-stretch
Normal file
18
Dockerfile-stretch
Normal file
|
@ -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/
|
|
@ -123,3 +123,17 @@ git clone https://github.com/abraunegg/onedrive
|
||||||
cd onedrive
|
cd onedrive
|
||||||
docker build . -t local-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
|
||||||
|
```
|
||||||
|
|
|
@ -22,12 +22,14 @@ class Progress
|
||||||
|
|
||||||
|
|
||||||
size_t getTerminalWidth() {
|
size_t getTerminalWidth() {
|
||||||
size_t column;
|
size_t column = default_width;
|
||||||
|
version (CRuntime_Musl) {
|
||||||
|
} else {
|
||||||
winsize ws;
|
winsize ws;
|
||||||
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1) {
|
if(ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) != -1 && ws.ws_col > 0) {
|
||||||
column = ws.ws_col;
|
column = ws.ws_col;
|
||||||
}
|
}
|
||||||
if(column == 0) column = default_width;
|
}
|
||||||
|
|
||||||
return column;
|
return column;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue