adapt other Dockerfiles

This commit is contained in:
Nils Domrose 2019-05-28 11:56:49 +02:00
parent 4859932d35
commit 6f7220b68e
4 changed files with 37 additions and 8 deletions

View File

@ -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/*

View File

@ -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
@ -48,6 +60,7 @@ ENV SSL_CERT_DIR=/etc/ssl/certs
# Install needed libraries
RUN apk add \
openssl \
mariadb-connector-c \
ca-certificates \
&& rm /var/cache/apk/*

View File

@ -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/*

View File

@ -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/*