mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-21 15:16:36 +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
|
||||
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 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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue