From 6f7220b68ed9f718efd72979b9f0d34c5105c939 Mon Sep 17 00:00:00 2001 From: Nils Domrose Date: Tue, 28 May 2019 11:56:49 +0200 Subject: [PATCH] adapt other Dockerfiles --- Dockerfile.aarch64 | 9 +++++++-- Dockerfile.alpine | 17 +++++++++++++++-- Dockerfile.armv6 | 9 +++++++-- Dockerfile.armv7 | 10 ++++++++-- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Dockerfile.aarch64 b/Dockerfile.aarch64 index 3d84629..c151d9b 100644 --- a/Dockerfile.aarch64 +++ b/Dockerfile.aarch64 @@ -23,6 +23,9 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust as build +# set sqlite as default for DB ARG for backward comaptibility +ARG DB=sqlite + RUN apt-get update \ && apt-get install -y \ gcc-aarch64-linux-gnu \ @@ -42,7 +45,8 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get update \ && apt-get install -y \ libssl-dev:arm64 \ - libc6-dev:arm64 + libc6-dev:arm64 \ + libmariadb-dev:arm64 ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" @@ -55,7 +59,7 @@ COPY . . # Build RUN rustup target add aarch64-unknown-linux-gnu -RUN cargo build --release --target=aarch64-unknown-linux-gnu -v +RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu -v ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -72,6 +76,7 @@ RUN [ "cross-build-start" ] RUN apt-get update && apt-get install -y\ openssl\ ca-certificates\ + libmariadbclient-dev\ --no-install-recommends\ && rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 2154ca1..8d7eefc 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -22,8 +22,17 @@ RUN ls # Musl build image for statically compiled binary FROM clux/muslrust:nightly-2018-12-01 as build +# set sqlite as default for DB ARG for backward comaptibility +ARG DB=sqlite + ENV USER "root" +# Install needed libraries +RUN apt-get update && apt-get install -y\ + libmysqlclient-dev\ + --no-install-recommends\ + && rm -rf /var/lib/apt/lists/* + WORKDIR /app # Copies the complete project @@ -32,8 +41,11 @@ COPY . . RUN rustup target add x86_64-unknown-linux-musl +# Make sure that we actually build the project +RUN touch src/main.rs + # Build -RUN cargo build --release +RUN cargo build --features ${DB} --release ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -47,7 +59,8 @@ ENV SSL_CERT_DIR=/etc/ssl/certs # Install needed libraries RUN apk add \ - openssl\ + openssl \ + mariadb-connector-c \ ca-certificates \ && rm /var/cache/apk/* diff --git a/Dockerfile.armv6 b/Dockerfile.armv6 index 3f4514f..a99f73e 100644 --- a/Dockerfile.armv6 +++ b/Dockerfile.armv6 @@ -23,6 +23,9 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust as build +# set sqlite as default for DB ARG for backward comaptibility +ARG DB=sqlite + RUN apt-get update \ && apt-get install -y \ gcc-arm-linux-gnueabi \ @@ -42,7 +45,8 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get update \ && apt-get install -y \ libssl-dev:armel \ - libc6-dev:armel + libc6-dev:armel \ + libmariadb-dev:armel ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" @@ -55,7 +59,7 @@ COPY . . # Build RUN rustup target add arm-unknown-linux-gnueabi -RUN cargo build --release --target=arm-unknown-linux-gnueabi -v +RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi -v ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -72,6 +76,7 @@ RUN [ "cross-build-start" ] RUN apt-get update && apt-get install -y\ openssl\ ca-certificates\ + libmariadbclient-dev\ --no-install-recommends\ && ln -s /lib/ld-linux-armhf.so.3 /lib/ld-linux.so.3\ && rm -rf /var/lib/apt/lists/* diff --git a/Dockerfile.armv7 b/Dockerfile.armv7 index ef1e347..c93988f 100644 --- a/Dockerfile.armv7 +++ b/Dockerfile.armv7 @@ -23,6 +23,9 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust as build +# set sqlite as default for DB ARG for backward comaptibility +ARG DB=sqlite + RUN apt-get update \ && apt-get install -y \ gcc-arm-linux-gnueabihf \ @@ -42,7 +45,9 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get update \ && apt-get install -y \ libssl-dev:armhf \ - libc6-dev:armhf + libc6-dev:armhf \ + libmariadb-dev:armhf + ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" ENV CROSS_COMPILE="1" @@ -55,7 +60,7 @@ COPY . . # Build RUN rustup target add armv7-unknown-linux-gnueabihf -RUN cargo build --release --target=armv7-unknown-linux-gnueabihf -v +RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf -v ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -72,6 +77,7 @@ RUN [ "cross-build-start" ] RUN apt-get update && apt-get install -y\ openssl\ ca-certificates\ + libmariadbclient-dev\ --no-install-recommends\ && rm -rf /var/lib/apt/lists/*