Improved Dockerfiles (#1795)

* Update Dockerfiles to use more modern base Linux distribution
This commit is contained in:
abraunegg 2022-03-07 19:25:34 +11:00 committed by GitHub
parent ff78e84efd
commit 8687deec18
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 175 additions and 110 deletions

View file

@ -1,26 +1,38 @@
FROM centos:7
ENV GOSU_VERSION=1.11
# -*-Dockerfile-*-
ARG FEDORA_VERSION=35
ARG DEBIAN_VERSION=bullseye
ARG GO_VERSION=1.17
ARG GOSU_VERSION=1.14
FROM golang:${GO_VERSION}-${DEBIAN_VERSION} AS builder-gosu
ARG GOSU_VERSION
RUN go install -ldflags "-s -w" github.com/tianon/gosu@${GOSU_VERSION}
FROM fedora:${FEDORA_VERSION} AS builder-onedrive
RUN dnf install -y ldc pkgconf libcurl-devel sqlite-devel
ENV PKG_CONFIG=/usr/bin/pkgconf
RUN yum install -y make git gcc libcurl-devel sqlite-devel pkg-config && \
yum install -y http://downloads.dlang.org/releases/2.x/2.097.0/dmd-2.097.0-0.fedora.x86_64.rpm && \
rm -rf /var/cache/yum/ && \
# gosu installation
gpg --keyserver hkps://keys.openpgp.org --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4 \
&& curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64" \
&& curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/${GOSU_VERSION}/gosu-amd64.asc" \
&& gpg --verify /usr/local/bin/gosu.asc \
&& rm /usr/local/bin/gosu.asc \
&& rm -r /root/.gnupg/ \
&& chmod +x /usr/local/bin/gosu \
&& gosu nobody true
RUN mkdir -p /onedrive/conf /onedrive/data
COPY . /usr/src/onedrive
WORKDIR /usr/src/onedrive
RUN ./configure && \
make clean && \
make && \
make install
COPY contrib/docker/entrypoint.sh /entrypoint.sh
VOLUME ["/onedrive/conf"]
RUN ./configure \
&& make clean \
&& make \
&& make install
FROM fedora:${FEDORA_VERSION}
RUN dnf install -y libcurl sqlite ldc-libs \
&& dnf clean all \
&& mkdir -p /onedrive/conf /onedrive/data
COPY --from=builder-gosu /go/bin/gosu /usr/local/bin/
COPY --from=builder-onedrive /usr/local/bin/onedrive /usr/local/bin/
COPY contrib/docker/entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -1,21 +0,0 @@
# -*-Dockerfile-*-
FROM debian:stretch
RUN apt update && \
apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config wget git
RUN wget https://github.com/ldc-developers/ldc/releases/download/v1.17.0/ldc2-1.17.0-linux-aarch64.tar.xz && \
tar -xvf ldc2-1.17.0-linux-aarch64.tar.xz
COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
./configure DC=/ldc2-1.17.0-linux-aarch64/bin/ldmd2 && \
make clean && \
make && \
make install
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 contrib/docker/entrypoint.sh /
COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/

View file

@ -1,21 +1,35 @@
# -*-Dockerfile-*-
FROM alpine:3.14
RUN apk add \
alpine-sdk gnupg xz curl-dev sqlite-dev binutils-gold \
autoconf automake ldc go
RUN go get github.com/tianon/gosu
COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
autoreconf -fiv && \
./configure && \
make clean && \
make && \
make install
FROM alpine:3.14
ENTRYPOINT ["/entrypoint.sh"]
RUN apk add --no-cache \
bash libcurl libgcc shadow sqlite-libs ldc-runtime && \
mkdir -p /onedrive/conf /onedrive/data
ARG ALPINE_VERSION=3.15
ARG GO_VERSION=1.17
ARG GOSU_VERSION=1.14
FROM golang:${GO_VERSION}-alpine${ALPINE_VERSION} AS builder-gosu
ARG GOSU_VERSION
RUN go install -ldflags "-s -w" github.com/tianon/gosu@${GOSU_VERSION}
FROM alpine:${ALPINE_VERSION} AS builder-onedrive
RUN apk add --update --no-cache alpine-sdk gnupg xz curl-dev sqlite-dev binutils-gold autoconf automake ldc
COPY . /usr/src/onedrive
WORKDIR /usr/src/onedrive
RUN autoreconf -fiv \
&& ./configure \
&& make clean \
&& make \
&& make install
FROM alpine:${ALPINE_VERSION}
RUN apk add --update --no-cache bash libcurl libgcc shadow sqlite-libs ldc-runtime \
&& mkdir -p /onedrive/conf /onedrive/data
COPY --from=builder-gosu /go/bin/gosu /usr/local/bin/
COPY --from=builder-onedrive /usr/local/bin/onedrive /usr/local/bin/
COPY contrib/docker/entrypoint.sh /
COPY --from=0 /root/go/bin/gosu /usr/local/bin/onedrive /usr/local/bin/
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -0,0 +1,54 @@
# -*-Dockerfile-*-
ARG DEBIAN_VERSION=bullseye
ARG LDC_VERSION_MAIN=1.28.1
FROM debian:${DEBIAN_VERSION} AS builder-onedrive
ARG LDC_VERSION_MAIN
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential curl ca-certificates libcurl4-openssl-dev libsqlite3-dev libxml2-dev pkg-config \
&& rm -rf /var/lib/apt/lists/*
RUN ARCH="$(dpkg --print-architecture)" \
&& case "${ARCH}" in \
aarch64|arm64) \
BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-aarch64.tar.xz"; \
;; \
amd64|x86-64) \
BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-x86_64.tar.xz"; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac \
&& echo ${BINARY_URL} \
&& curl -k -LfsSo /tmp/ldc.tar.xz ${BINARY_URL} \
&& mkdir -p /opt/ldc \
&& tar -xvf /tmp/ldc.tar.xz -C /opt/ldc --strip-components=1 \
&& rm -rf /tmp/ldc.tar.xz
COPY . /usr/src/onedrive
WORKDIR /usr/src/onedrive
RUN ./configure DC=/opt/ldc/bin/ldmd2 \
&& make clean \
&& make \
&& make install
FROM debian:${DEBIAN_VERSION}-slim
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gosu libcurl4 libsqlite3-0 ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
# Fix bug with ssl on armhf: https://serverfault.com/a/1045189
&& /usr/bin/c_rehash \
&& mkdir -p /onedrive/conf /onedrive/data
COPY --from=builder-onedrive /usr/local/bin/onedrive /usr/local/bin/
COPY contrib/docker/entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -1,21 +1,51 @@
# -*-Dockerfile-*-
FROM debian:stretch
RUN apt update && \
apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config wget git
RUN wget https://github.com/ldc-developers/ldc/releases/download/v1.17.0/ldc2-1.17.0-linux-armhf.tar.xz && \
tar -xvf ldc2-1.17.0-linux-armhf.tar.xz
COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
./configure DC=/ldc2-1.17.0-linux-armhf/bin/ldmd2 && \
make clean && \
make && \
make install
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
ARG DEBIAN_VERSION=buster
ARG LDC_VERSION_MAIN=1.17.0
FROM debian:${DEBIAN_VERSION} AS builder-onedrive
ARG LDC_VERSION_MAIN
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential curl ca-certificates libcurl4-openssl-dev libsqlite3-dev libxml2-dev pkg-config \
&& rm -rf /var/lib/apt/lists/*
RUN ARCH="$(dpkg --print-architecture)" \
&& case "${ARCH}" in \
armhf|arm) \
BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-aarch64.tar.xz"; \
;; \
*) \
echo "Unsupported arch: ${ARCH}"; \
exit 1; \
;; \
esac \
&& echo ${BINARY_URL} \
&& curl -k -LfsSo /tmp/ldc.tar.xz ${BINARY_URL} \
&& mkdir -p /opt/ldc \
&& tar -xvf /tmp/ldc.tar.xz -C /opt/ldc --strip-components=1 \
&& rm -rf /tmp/ldc.tar.xz
COPY . /usr/src/onedrive
WORKDIR /usr/src/onedrive
RUN ./configure DC=/opt/ldc/bin/ldmd2 \
&& make clean \
&& make \
&& make install
FROM debian:${DEBIAN_VERSION}-slim
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gosu libcurl4 libsqlite3-0 ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
# Fix bug with ssl on armhf: https://serverfault.com/a/1045189
&& /usr/bin/c_rehash \
&& mkdir -p /onedrive/conf /onedrive/data
COPY --from=builder-onedrive /usr/local/bin/onedrive /usr/local/bin/
COPY contrib/docker/entrypoint.sh /
COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]

View file

@ -1,23 +0,0 @@
# -*-Dockerfile-*-
FROM debian:stretch
RUN apt update && \
apt install -y build-essential curl libcurl4-openssl-dev libsqlite3-dev pkg-config git wget
RUN wget http://downloads.dlang.org/releases/2.x/2.097.0/dmd_2.097.0-0_amd64.deb -O /tmp/dmd_amd64.deb && \
dpkg -i /tmp/dmd_amd64.deb
RUN rm -f /tmp/dmd_amd64.deb
COPY . /usr/src/onedrive
RUN cd /usr/src/onedrive/ && \
./configure && \
make clean && \
make && \
make install
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 contrib/docker/entrypoint.sh /
COPY --from=0 /usr/local/bin/onedrive /usr/local/bin/

View file

@ -1,7 +1,7 @@
# Run the OneDrive Client for Linux under Docker
This client can be run as a Docker container, with 3 available options for you to choose from:
1. Container based on CentOS 7 - Docker Tag: latest
2. Container based on Debian Stretch - Docker Tag: stretch
1. Container based on Fedora 35 - Docker Tag: latest
2. Container based on Debian 11 - Docker Tag: debian
3. Container based on Alpine Linux - Docker Tag: alpine
These containers offer a simple monitoring-mode service for the OneDrive Client for Linux.
@ -10,8 +10,7 @@ The instructions below have been validated on:
* Red Hat Enterprise Linux 8.x
* Ubuntu Server 20.04
The instructions below will utilise the 'latest' tag, however this can be substituted for 'stretch' or 'alpine' if desired.
The instructions below will utilise the 'latest' tag, however this can be substituted for 'debian' or 'alpine' if desired.
## Basic Setup
### 0. Install docker using your distribution platform's instructions
@ -253,14 +252,14 @@ docker build . -t local-onedrive -f contrib/docker/Dockerfile
```
There are alternate, smaller images available by building
Dockerfile-stretch or Dockerfile-alpine. These [multi-stage builder
Dockerfile-debian 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.
#### How to build and run a custom Docker image based on Debian Stretch
#### How to build and run a custom Docker image based on Debian
``` bash
docker build . -t local-ondrive-stretch -f contrib/docker/Dockerfile-stretch
docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" local-ondrive-stretch:latest
docker build . -t local-ondrive-debian -f contrib/docker/Dockerfile-debian
docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" local-ondrive-debian:latest
```
#### How to build and run a custom Docker image based on Alpine Linux
@ -283,6 +282,6 @@ docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/o
#### How to build and run a custom Docker image for AARCH64 Platforms
``` bash
docker build . -t local-onedrive-aarch64 -f contrib/docker/Dockerfile-aarch64
docker build . -t local-onedrive-aarch64 -f contrib/docker/Dockerfile-debian
docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" local-onedrive-aarch64:latest
```