From f250c5481302280360a89c25a5fd02607b91c53f Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 24 Dec 2019 00:26:34 +0100 Subject: [PATCH 01/17] WIP: Use Debian base image for all steps of the build process No need to use two different base images. Debian buster is pulled later anyway so we can just use it for the vault stage as well. My reason for this change is partly to avoid redundancy and partly to make it easier to build everything yourself. When all the build environment is based on Debian than you just have to figure out how to build a Debian Docker base image (ref: https://github.com/ypid/docker-makefile). --- docker/amd64/sqlite/Dockerfile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 086b34ba..103c2f9d 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -2,20 +2,26 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM debian:buster-slim as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls From 8280d200ea6c39757783f02756eb45141d3e50fe Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Sat, 28 Dec 2019 22:52:01 +0100 Subject: [PATCH 02/17] Generate Dockerfiles from one source for maintainability. Closes #785. --- docker/Dockerfile.j2 | 276 ++++++++++++++++++++++ docker/Makefile | 9 + docker/aarch64/mysql/Dockerfile | 52 +++- docker/aarch64/sqlite/Dockerfile | 45 +++- docker/amd64/mysql/Dockerfile | 19 +- docker/amd64/mysql/Dockerfile.alpine | 31 ++- docker/amd64/postgresql/Dockerfile | 30 +-- docker/amd64/postgresql/Dockerfile.alpine | 30 ++- docker/amd64/sqlite/Dockerfile | 5 +- docker/amd64/sqlite/Dockerfile.alpine | 28 ++- docker/armv6/mysql/Dockerfile | 52 +++- docker/armv6/sqlite/Dockerfile | 45 +++- docker/armv7/mysql/Dockerfile | 64 ++--- docker/armv7/sqlite/Dockerfile | 60 ++--- docker/render_template | 17 ++ 15 files changed, 615 insertions(+), 148 deletions(-) create mode 100644 docker/Dockerfile.j2 create mode 100644 docker/Makefile create mode 100755 docker/render_template diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 new file mode 100644 index 00000000..0298a334 --- /dev/null +++ b/docker/Dockerfile.j2 @@ -0,0 +1,276 @@ +# Using multistage build: +# https://docs.docker.com/develop/develop-images/multistage-build/ +# https://whitfin.io/speeding-up-rust-docker-builds/ +####################### VAULT BUILD IMAGE ####################### +{% if "alpine" in target_file %} +{% set preferred_base_image = "alpine:3.11" %} +{% set package_arch_name = "" %} +{% elif "amd64" in target_file %} +{% set preferred_base_image = "debian:buster-slim" %} +{% set package_arch_name = "" %} +{% elif "aarch64" in target_file %} +{% set preferred_base_image = "balenalib/aarch64-debian:buster" %} +{% set package_arch_name = "arm64" %} +{% elif "armv6" in target_file %} +{% set preferred_base_image = "balenalib/rpi-debian:buster" %} +{% set package_arch_name = "armel" %} +{% elif "armv7" in target_file %} +{% set preferred_base_image = "balenalib/armv7hf-debian:buster" %} +{% set package_arch_name = "armhf" %} +{% endif %} +{% set package_arch_prefix = ":" + package_arch_name %} +{% if package_arch_name == "" %} +{% set package_arch_prefix = "" %} +{% endif %} +FROM {{ preferred_base_image }} as vault + +ENV VAULT_VERSION "v2.12.0b" + +ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" + +{% if "alpine" in target_file %} +RUN apk add --no-cache --upgrade \ + curl \ + tar +{% else %} +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar +{% endif %} + +RUN mkdir /web-vault +WORKDIR /web-vault + +{% if "alpine" in target_file %} +SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] +{% else %} +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] +{% endif %} + +RUN curl -L $URL | tar xz +RUN ls + +########################## BUILD IMAGE ########################## +{% if "alpine" in target_file %} +# Musl build image for statically compiled binary +FROM clux/muslrust:nightly-2019-12-19 as build +{% else %} +# We need to use the Rust build image, because +# we need the Rust compiler and Cargo tooling +FROM rust:1.40 as build +{% endif %} + +{% if "sqlite" in target_file %} +# set sqlite as default for DB ARG for backward compatibility +ARG DB=sqlite +{% elif "mysql" in target_file %} +# set mysql backend +ARG DB=mysql +{% elif "postgresql" in target_file %} +# set postgresql backend +ARG DB=postgresql +{% endif %} + +# Don't download rust docs +RUN rustup set profile minimal + +{% if "alpine" in target_file %} +ENV USER "root" + +{% endif %} +{% if "aarch64" in target_file %} +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-aarch64-linux-gnu \ + && mkdir -p ~/.cargo \ + && echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config \ + && echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + +{% elif "armv6" in target_file %} +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-arm-linux-gnueabi \ + && mkdir -p ~/.cargo \ + && echo '[target.arm-unknown-linux-gnueabi]' >> ~/.cargo/config \ + && echo 'linker = "arm-linux-gnueabi-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + +{% elif "armv6" in target_file %} +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-arm-linux-gnueabihf \ + && mkdir -p ~/.cargo \ + && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ + && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + +{% endif %} +{% if "mysql" in target_file %} +# Install MySQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libmariadb-dev{{ package_arch_prefix }} \ + && rm -rf /var/lib/apt/lists/* + +{% elif "postgresql" in target_file %} +# Install PostgreSQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libpq-dev{{ package_arch_prefix }} \ + && rm -rf /var/lib/apt/lists/* + +{% endif %} +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app +WORKDIR /app + +{% if "aarch64" in target_file or "armv" in target_file %} +# Install required build libs for {{ package_arch_name }} architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture {{ package_arch_name }} \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev{{ package_arch_prefix }} \ + libc6-dev{{ package_arch_prefix }} + +{% endif -%} + +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + +{% if "aarch64" in target_file %} +ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" +ENV CROSS_COMPILE="1" +ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" +ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +{% elif "armv6" in target_file %} +ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" +ENV CROSS_COMPILE="1" +ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" +ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +{% endif -%} + +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete + +# Copies the complete project +# To avoid copying unneeded files, use .dockerignore +COPY . . + +# Make sure that we actually build the project +RUN touch src/main.rs + +{% if "alpine" in target_file %} +RUN rustup target add x86_64-unknown-linux-musl + +{% endif %} +# Builds again, this time it'll just be +# your actual source files being built +{% if "amd64" in target_file %} +RUN cargo build --features ${DB} --release +{% elif "aarch64" in target_file %} +RUN rustup target add aarch64-unknown-linux-gnu +RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu +{% endif %} + +######################## RUNTIME IMAGE ######################## +# Create a new stage with a minimal image +# because we already have a binary built +FROM {{ preferred_base_image }} + +ENV ROCKET_ENV "staging" +ENV ROCKET_PORT=80 +ENV ROCKET_WORKERS=10 +{% if "alpine" in target_file %} +ENV SSL_CERT_DIR=/etc/ssl/certs +{% endif %} + +{% if "amd64" not in target_file %} +RUN [ "cross-build-start" ] +{% endif %} + +# Install needed libraries +{% if "alpine" in target_file %} +RUN apk add --no-cache \ + openssl \ + curl \ +{% if "sqlite" in target_file %} + sqlite \ +{% elif "mysql" in target_file %} + mariadb-connector-c \ +{% elif "postgresql" in target_file %} + postgresql-libs \ +{% endif %} + ca-certificates +{% else %} +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + openssl \ + ca-certificates \ + curl \ +{% if "sqlite" in target_file %} + sqlite3 \ +{% elif "mysql" in target_file %} + libmariadbclient-dev \ +{% elif "postgresql" in target_file %} + libpq5 \ +{% endif %} + && rm -rf /var/lib/apt/lists/* +{% endif %} + +RUN mkdir /data +{% if "amd64" not in target_file %} + +RUN [ "cross-build-end" ] + +{% endif %} +VOLUME /data +EXPOSE 80 +EXPOSE 3012 + +# Copies the files from the context (Rocket.toml file and web-vault) +# and the binary from the "build" stage to the current stage +COPY Rocket.toml . +COPY --from=vault /web-vault ./web-vault +{% if "alpine" in target_file %} +COPY --from=build /app/target/x86_64-unknown-linux-musl/release/bitwarden_rs . +{% elif "aarch64" in target_file %} +COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/bitwarden_rs . +{% elif "armv6" in target_file %} +COPY --from=build /app/target/arm-unknown-linux-gnueabi/release/bitwarden_rs . +{% elif "armv7" in target_file %} +COPY --from=build /app/target/armv7-unknown-linux-gnueabihf/release/bitwarden_rs . +{% else %} +COPY --from=build app/target/release/bitwarden_rs . +{% endif %} + +COPY docker/healthcheck.sh ./healthcheck.sh + +HEALTHCHECK --interval=30s --timeout=3s CMD sh healthcheck.sh || exit 1 + +# Configures the startup! +WORKDIR / +CMD ["/bitwarden_rs"] diff --git a/docker/Makefile b/docker/Makefile new file mode 100644 index 00000000..f73200a5 --- /dev/null +++ b/docker/Makefile @@ -0,0 +1,9 @@ +OBJECTS := $(shell find -mindepth 2 -name 'Dockerfile*') + +all: $(OBJECTS) + +%/Dockerfile: Dockerfile.j2 render_template + ./render_template "$<" "{\"target_file\":\"$@\"}" > "$@" + +%/Dockerfile.alpine: Dockerfile.j2 render_template + ./render_template "$<" "{\"target_file\":\"$@\"}" > "$@" diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e435d86c..e0b06554 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/aarch64-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -42,9 +48,17 @@ RUN apt-get update \ ENV CARGO_HOME "/root/.cargo" ENV USER "root" +# Install MySQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libmariadb-dev:arm64 \ + && rm -rf /var/lib/apt/lists/* + +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl arm64 libs +# Install required build libs for arm64 architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture arm64 \ @@ -52,19 +66,32 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get install -y \ --no-install-recommends \ libssl-dev:arm64 \ - libc6-dev:arm64 \ - libmariadb-dev:arm64 + libc6-dev:arm64 + +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu @@ -86,14 +113,15 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ curl \ libmariadbclient-dev \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index c703d0f5..e63e755e 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/aarch64-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -25,7 +31,7 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust:1.40 as build -# set sqlite as default for DB ARG for backward comaptibility +# set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite # Don't download rust docs @@ -42,9 +48,11 @@ RUN apt-get update \ ENV CARGO_HOME "/root/.cargo" ENV USER "root" +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl arm64 libs +# Install required build libs for arm64 architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture arm64 \ @@ -54,16 +62,30 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:arm64 \ libc6-dev:arm64 +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu @@ -85,14 +107,15 @@ RUN apt-get update && apt-get install -y \ ca-certificates \ curl \ sqlite3 \ - && rm -rf /var/lib/apt/lists/* + && rm -rf /var/lib/apt/lists/* RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 19d2e5be..8d789c82 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM debian:buster-slim as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -72,6 +78,7 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 + # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 8830d5ff..a3d11b19 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -1,4 +1,4 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### @@ -15,7 +15,7 @@ RUN apk add --no-cache --upgrade \ RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -32,24 +32,38 @@ RUN rustup set profile minimal ENV USER "root" -# Install needed libraries +# Install MySQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ - libmysqlclient-dev \ + libmariadb-dev \ && rm -rf /var/lib/apt/lists/* +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete + # Copies the complete project # To avoid copying unneeded files, use .dockerignore 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 rustup target add x86_64-unknown-linux-musl + +# Builds again, this time it'll just be +# your actual source files being built RUN cargo build --features ${DB} --release ######################## RUNTIME IMAGE ######################## @@ -62,11 +76,12 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs + # Install needed libraries RUN apk add --no-cache \ openssl \ - mariadb-connector-c \ curl \ + mariadb-connector-c \ ca-certificates RUN mkdir /data diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index 675cd3cc..7b9818a6 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM debian:buster-slim as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -25,19 +31,13 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust:1.40 as build -# set mysql backend +# set postgresql backend ARG DB=postgresql # Don't download rust docs RUN rustup set profile minimal -# Using bundled SQLite, no need to install it -# RUN apt-get update && apt-get install -y\ -# --no-install-recommends \ -# sqlite3\ -# && rm -rf /var/lib/apt/lists/* - -# Install MySQL package +# Install PostgreSQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ libpq-dev \ @@ -78,13 +78,13 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 + # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ openssl \ ca-certificates \ curl \ - sqlite3 \ libpq5 \ && rm -rf /var/lib/apt/lists/* diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index d527bff4..7177698f 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -1,4 +1,4 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### @@ -15,7 +15,7 @@ RUN apk add --no-cache --upgrade \ RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -32,24 +32,38 @@ RUN rustup set profile minimal ENV USER "root" -# Install needed libraries +# Install PostgreSQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ libpq-dev \ && rm -rf /var/lib/apt/lists/* +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete + # Copies the complete project # To avoid copying unneeded files, use .dockerignore 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 rustup target add x86_64-unknown-linux-musl + +# Builds again, this time it'll just be +# your actual source files being built RUN cargo build --features ${DB} --release ######################## RUNTIME IMAGE ######################## @@ -62,12 +76,12 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs + # Install needed libraries RUN apk add --no-cache \ openssl \ - postgresql-libs \ curl \ - sqlite \ + postgresql-libs \ ca-certificates RUN mkdir /data diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 103c2f9d..55a5dc04 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -1,4 +1,4 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### @@ -31,7 +31,7 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust:1.40 as build -# set sqlite as default for DB ARG for backward comaptibility +# set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite # Don't download rust docs @@ -72,6 +72,7 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 + # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index c3313395..3a1ca323 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -1,4 +1,4 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### @@ -15,7 +15,7 @@ RUN apk add --no-cache --upgrade \ RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -24,7 +24,7 @@ RUN ls # Musl build image for statically compiled binary FROM clux/muslrust:nightly-2019-12-19 as build -# set sqlite as default for DB ARG for backward comaptibility +# set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite # Don't download rust docs @@ -32,18 +32,32 @@ RUN rustup set profile minimal ENV USER "root" +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete + # Copies the complete project # To avoid copying unneeded files, use .dockerignore 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 rustup target add x86_64-unknown-linux-musl + +# Builds again, this time it'll just be +# your actual source files being built RUN cargo build --features ${DB} --release ######################## RUNTIME IMAGE ######################## @@ -56,6 +70,7 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs + # Install needed libraries RUN apk add --no-cache \ openssl \ @@ -78,7 +93,6 @@ COPY docker/healthcheck.sh ./healthcheck.sh HEALTHCHECK --interval=30s --timeout=3s CMD sh healthcheck.sh || exit 1 - # Configures the startup! WORKDIR / CMD ["/bitwarden_rs"] diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index f78bc4fb..d05c21aa 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/rpi-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -42,9 +48,17 @@ RUN apt-get update \ ENV CARGO_HOME "/root/.cargo" ENV USER "root" +# Install MySQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libmariadb-dev:armel \ + && rm -rf /var/lib/apt/lists/* + +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl armel libs +# Install required build libs for armel architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture armel \ @@ -52,21 +66,32 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get install -y \ --no-install-recommends \ libssl-dev:armel \ - libc6-dev:armel \ - libmariadb-dev:armel + libc6-dev:armel + +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build -RUN rustup target add arm-unknown-linux-gnueabi -RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -90,10 +115,11 @@ RUN apt-get update && apt-get install -y \ RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index af3ed2e3..64255111 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/rpi-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -25,7 +31,7 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust:1.40 as build -# set sqlite as default for DB ARG for backward comaptibility +# set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite # Don't download rust docs @@ -42,9 +48,11 @@ RUN apt-get update \ ENV CARGO_HOME "/root/.cargo" ENV USER "root" +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl armel libs +# Install required build libs for armel architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture armel \ @@ -54,18 +62,30 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armel \ libc6-dev:armel +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build -RUN rustup target add arm-unknown-linux-gnueabi -RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -89,10 +109,11 @@ RUN apt-get update && apt-get install -y \ RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 44a40a15..90bb9d6a 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/armv7hf-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -31,20 +37,17 @@ ARG DB=mysql # Don't download rust docs RUN rustup set profile minimal -RUN apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - gcc-arm-linux-gnueabihf \ - && mkdir -p ~/.cargo \ - && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ - && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config - -ENV CARGO_HOME "/root/.cargo" -ENV USER "root" +# Install MySQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libmariadb-dev:armhf \ + && rm -rf /var/lib/apt/lists/* +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl armhf libs +# Install required build libs for armhf architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture armhf \ @@ -52,22 +55,28 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ && apt-get install -y \ --no-install-recommends \ libssl-dev:armhf \ - libc6-dev:armhf \ - libmariadb-dev:armhf + libc6-dev:armhf +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs -ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" -ENV CROSS_COMPILE="1" -ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabihf" -ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabihf" +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build -RUN rustup target add armv7-unknown-linux-gnueabihf -RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -91,10 +100,11 @@ RUN apt-get update && apt-get install -y \ RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 34f44ec2..28851b67 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -1,21 +1,27 @@ -# Using multistage build: +# Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM alpine:3.11 as vault +FROM balenalib/armv7hf-debian:buster as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -RUN apk add --no-cache --upgrade \ - curl \ - tar +ENV DEBIAN_FRONTEND=noninteractive \ + LANG=C.UTF-8 \ + TZ=UTC \ + TERM=xterm-256color + +RUN apt update -y \ + && apt install -y \ + curl \ + tar RUN mkdir /web-vault WORKDIR /web-vault -SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] RUN curl -L $URL | tar xz RUN ls @@ -25,26 +31,17 @@ RUN ls # we need the Rust compiler and Cargo tooling FROM rust:1.40 as build -# set sqlite as default for DB ARG for backward comaptibility +# set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite # Don't download rust docs RUN rustup set profile minimal -RUN apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - gcc-arm-linux-gnueabihf \ - && mkdir -p ~/.cargo \ - && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ - && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config - -ENV CARGO_HOME "/root/.cargo" -ENV USER "root" - +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app WORKDIR /app -# Prepare openssl armhf libs +# Install required build libs for armhf architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ && dpkg --add-architecture armhf \ @@ -54,18 +51,26 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armhf \ libc6-dev:armhf -ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" -ENV CROSS_COMPILE="1" -ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabihf" -ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabihf" +# Copies over *only* your manifests and build files +COPY ./Cargo.* ./ +COPY ./rust-toolchain ./rust-toolchain +COPY ./build.rs ./build.rs + +# Builds your dependencies and removes the +# dummy project, except the target folder +# This folder contains the compiled dependencies +RUN cargo build --features ${DB} --release +RUN find . -not -path "./target*" -delete # Copies the complete project # To avoid copying unneeded files, use .dockerignore COPY . . -# Build -RUN rustup target add armv7-unknown-linux-gnueabihf -RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf +# Make sure that we actually build the project +RUN touch src/main.rs + +# Builds again, this time it'll just be +# your actual source files being built ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image @@ -89,10 +94,11 @@ RUN apt-get update && apt-get install -y \ RUN mkdir /data -RUN [ "cross-build-end" ] +RUN [ "cross-build-end" ] VOLUME /data EXPOSE 80 +EXPOSE 3012 # Copies the files from the context (Rocket.toml file and web-vault) # and the binary from the "build" stage to the current stage diff --git a/docker/render_template b/docker/render_template new file mode 100755 index 00000000..c9978d5a --- /dev/null +++ b/docker/render_template @@ -0,0 +1,17 @@ +#!/usr/bin/env python3 + +import os, argparse, json + +import jinja2 + +args_parser = argparse.ArgumentParser() +args_parser.add_argument('template_file', help='Jinja2 template file to render.') +args_parser.add_argument('render_vars', help='JSON-encoded data to pass to the templating engine.') +cli_args = args_parser.parse_args() + +render_vars = json.loads(cli_args.render_vars) +environment = jinja2.Environment( + loader=jinja2.FileSystemLoader(os.getcwd()), + trim_blocks=True, +) +print(environment.get_template(cli_args.template_file).render(render_vars)) From 43aa75dc89c60a994ed89a93b44622f01e9b90ba Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:13:43 +0100 Subject: [PATCH 03/17] Fix cross platform build support, thanks to @dani-garcia for the review --- docker/Dockerfile.j2 | 47 ++++++++++++++++-------------- docker/aarch64/mysql/Dockerfile | 2 +- docker/aarch64/sqlite/Dockerfile | 2 +- docker/amd64/mysql/Dockerfile | 2 +- docker/amd64/postgresql/Dockerfile | 2 +- docker/amd64/sqlite/Dockerfile | 2 +- docker/armv6/mysql/Dockerfile | 2 +- docker/armv6/sqlite/Dockerfile | 2 +- docker/armv7/mysql/Dockerfile | 2 +- docker/armv7/sqlite/Dockerfile | 2 +- 10 files changed, 34 insertions(+), 31 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 0298a334..f8cb0297 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -2,33 +2,37 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### +{% set build_stage_base_image = "rust:1.40" %} +{% set vault_stage_base_image = build_stage_base_image %} {% if "alpine" in target_file %} -{% set preferred_base_image = "alpine:3.11" %} +{% set build_stage_base_image = "clux/muslrust:nightly-2019-12-19" %} +{% set runtime_stage_base_image = "alpine:3.11" %} +{% set vault_stage_base_image = runtime_stage_base_image %} {% set package_arch_name = "" %} {% elif "amd64" in target_file %} -{% set preferred_base_image = "debian:buster-slim" %} +{% set runtime_stage_base_image = "debian:buster-slim" %} {% set package_arch_name = "" %} {% elif "aarch64" in target_file %} -{% set preferred_base_image = "balenalib/aarch64-debian:buster" %} +{% set runtime_stage_base_image = "balenalib/aarch64-debian:buster" %} {% set package_arch_name = "arm64" %} {% elif "armv6" in target_file %} -{% set preferred_base_image = "balenalib/rpi-debian:buster" %} +{% set runtime_stage_base_image = "balenalib/rpi-debian:buster" %} {% set package_arch_name = "armel" %} {% elif "armv7" in target_file %} -{% set preferred_base_image = "balenalib/armv7hf-debian:buster" %} +{% set runtime_stage_base_image = "balenalib/armv7hf-debian:buster" %} {% set package_arch_name = "armhf" %} {% endif %} {% set package_arch_prefix = ":" + package_arch_name %} {% if package_arch_name == "" %} {% set package_arch_prefix = "" %} {% endif %} -FROM {{ preferred_base_image }} as vault +FROM {{ vault_stage_base_image }} as vault ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -{% if "alpine" in target_file %} +{% if "alpine" in vault_stage_base_image %} RUN apk add --no-cache --upgrade \ curl \ tar @@ -47,7 +51,7 @@ RUN apt update -y \ RUN mkdir /web-vault WORKDIR /web-vault -{% if "alpine" in target_file %} +{% if "alpine" in vault_stage_base_image %} SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] {% else %} SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"] @@ -57,14 +61,13 @@ RUN curl -L $URL | tar xz RUN ls ########################## BUILD IMAGE ########################## -{% if "alpine" in target_file %} +{% if "musl" in build_stage_base_image %} # Musl build image for statically compiled binary -FROM clux/muslrust:nightly-2019-12-19 as build {% else %} # We need to use the Rust build image, because # we need the Rust compiler and Cargo tooling -FROM rust:1.40 as build {% endif %} +FROM {{ build_stage_base_image }} as build {% if "sqlite" in target_file %} # set sqlite as default for DB ARG for backward compatibility @@ -199,12 +202,12 @@ RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image # because we already have a binary built -FROM {{ preferred_base_image }} +FROM {{ runtime_stage_base_image }} ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 -{% if "alpine" in target_file %} +{% if "alpine" in runtime_stage_base_image %} ENV SSL_CERT_DIR=/etc/ssl/certs {% endif %} @@ -213,17 +216,17 @@ RUN [ "cross-build-start" ] {% endif %} # Install needed libraries -{% if "alpine" in target_file %} +{% if "alpine" in runtime_stage_base_image %} RUN apk add --no-cache \ openssl \ curl \ -{% if "sqlite" in target_file %} +{% if "sqlite" in target_file %} sqlite \ -{% elif "mysql" in target_file %} +{% elif "mysql" in target_file %} mariadb-connector-c \ -{% elif "postgresql" in target_file %} +{% elif "postgresql" in target_file %} postgresql-libs \ -{% endif %} +{% endif %} ca-certificates {% else %} RUN apt-get update && apt-get install -y \ @@ -231,13 +234,13 @@ RUN apt-get update && apt-get install -y \ openssl \ ca-certificates \ curl \ -{% if "sqlite" in target_file %} +{% if "sqlite" in target_file %} sqlite3 \ -{% elif "mysql" in target_file %} +{% elif "mysql" in target_file %} libmariadbclient-dev \ -{% elif "postgresql" in target_file %} +{% elif "postgresql" in target_file %} libpq5 \ -{% endif %} +{% endif %} && rm -rf /var/lib/apt/lists/* {% endif %} diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e0b06554..6562d4d8 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/aarch64-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index e63e755e..cea96491 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/aarch64-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 8d789c82..d59c8953 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM debian:buster-slim as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index 7b9818a6..bf1aa2f7 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM debian:buster-slim as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 55a5dc04..56cf4bee 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM debian:buster-slim as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index d05c21aa..ed389253 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/rpi-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 64255111..98afd9ba 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/rpi-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 90bb9d6a..6e32c8c9 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/armv7hf-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 28851b67..ba9bb117 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -2,7 +2,7 @@ # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ ####################### VAULT BUILD IMAGE ####################### -FROM balenalib/armv7hf-debian:buster as vault +FROM rust:1.40 as vault ENV VAULT_VERSION "v2.12.0b" From 0f0e5876aeaae3a97773540dc90b05daa9d462f4 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:17:31 +0100 Subject: [PATCH 04/17] Move `dpkg --add-architecture` before the first apt call Thanks to @dani-garcia for the review! --- docker/Dockerfile.j2 | 25 ++++++++++++------------- docker/aarch64/mysql/Dockerfile | 20 ++++++++++---------- docker/aarch64/sqlite/Dockerfile | 20 ++++++++++---------- docker/armv6/mysql/Dockerfile | 20 ++++++++++---------- docker/armv6/sqlite/Dockerfile | 20 ++++++++++---------- docker/armv7/mysql/Dockerfile | 20 ++++++++++---------- docker/armv7/sqlite/Dockerfile | 8 ++++---- 7 files changed, 66 insertions(+), 67 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index f8cb0297..dd64be42 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -87,6 +87,18 @@ RUN rustup set profile minimal ENV USER "root" {% endif %} +{% if "aarch64" in target_file or "armv" in target_file %} +# Install required build libs for {{ package_arch_name }} architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture {{ package_arch_name }} \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev{{ package_arch_prefix }} \ + libc6-dev{{ package_arch_prefix }} + +{% endif -%} {% if "aarch64" in target_file %} RUN apt-get update \ && apt-get install -y \ @@ -143,19 +155,6 @@ RUN apt-get update && apt-get install -y \ RUN USER=root cargo new --bin app WORKDIR /app -{% if "aarch64" in target_file or "armv" in target_file %} -# Install required build libs for {{ package_arch_name }} architecture. -RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ - /etc/apt/sources.list.d/deb-src.list \ - && dpkg --add-architecture {{ package_arch_name }} \ - && apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - libssl-dev{{ package_arch_prefix }} \ - libc6-dev{{ package_arch_prefix }} - -{% endif -%} - # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index 6562d4d8..e7ec2402 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -37,6 +37,16 @@ ARG DB=mysql # Don't download rust docs RUN rustup set profile minimal +# Install required build libs for arm64 architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture arm64 \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev:arm64 \ + libc6-dev:arm64 + RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ @@ -58,16 +68,6 @@ RUN apt-get update && apt-get install -y \ RUN USER=root cargo new --bin app WORKDIR /app -# Install required build libs for arm64 architecture. -RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ - /etc/apt/sources.list.d/deb-src.list \ - && dpkg --add-architecture arm64 \ - && apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - libssl-dev:arm64 \ - libc6-dev:arm64 - # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index cea96491..0945e573 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -37,6 +37,16 @@ ARG DB=sqlite # Don't download rust docs RUN rustup set profile minimal +# Install required build libs for arm64 architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture arm64 \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev:arm64 \ + libc6-dev:arm64 + RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ @@ -52,16 +62,6 @@ ENV USER "root" RUN USER=root cargo new --bin app WORKDIR /app -# Install required build libs for arm64 architecture. -RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ - /etc/apt/sources.list.d/deb-src.list \ - && dpkg --add-architecture arm64 \ - && apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - libssl-dev:arm64 \ - libc6-dev:arm64 - # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index ed389253..ceb2ba64 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -37,6 +37,16 @@ ARG DB=mysql # Don't download rust docs RUN rustup set profile minimal +# Install required build libs for armel architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture armel \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev:armel \ + libc6-dev:armel + RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ @@ -58,16 +68,6 @@ RUN apt-get update && apt-get install -y \ RUN USER=root cargo new --bin app WORKDIR /app -# Install required build libs for armel architecture. -RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ - /etc/apt/sources.list.d/deb-src.list \ - && dpkg --add-architecture armel \ - && apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - libssl-dev:armel \ - libc6-dev:armel - # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 98afd9ba..638cd983 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -37,6 +37,16 @@ ARG DB=sqlite # Don't download rust docs RUN rustup set profile minimal +# Install required build libs for armel architecture. +RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ + /etc/apt/sources.list.d/deb-src.list \ + && dpkg --add-architecture armel \ + && apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + libssl-dev:armel \ + libc6-dev:armel + RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ @@ -52,16 +62,6 @@ ENV USER "root" RUN USER=root cargo new --bin app WORKDIR /app -# Install required build libs for armel architecture. -RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ - /etc/apt/sources.list.d/deb-src.list \ - && dpkg --add-architecture armel \ - && apt-get update \ - && apt-get install -y \ - --no-install-recommends \ - libssl-dev:armel \ - libc6-dev:armel - # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 6e32c8c9..74265b45 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -37,16 +37,6 @@ ARG DB=mysql # Don't download rust docs RUN rustup set profile minimal -# Install MySQL package -RUN apt-get update && apt-get install -y \ - --no-install-recommends \ - libmariadb-dev:armhf \ - && rm -rf /var/lib/apt/lists/* - -# Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app -WORKDIR /app - # Install required build libs for armhf architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ @@ -57,6 +47,16 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armhf \ libc6-dev:armhf +# Install MySQL package +RUN apt-get update && apt-get install -y \ + --no-install-recommends \ + libmariadb-dev:armhf \ + && rm -rf /var/lib/apt/lists/* + +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app +WORKDIR /app + # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index ba9bb117..32bcb0b2 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -37,10 +37,6 @@ ARG DB=sqlite # Don't download rust docs RUN rustup set profile minimal -# Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app -WORKDIR /app - # Install required build libs for armhf architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ @@ -51,6 +47,10 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armhf \ libc6-dev:armhf +# Creates a dummy project used to grab dependencies +RUN USER=root cargo new --bin app +WORKDIR /app + # Copies over *only* your manifests and build files COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain From 47a5a4e1fcba7c89e6fba90a23c05b6353b0c013 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:28:23 +0100 Subject: [PATCH 05/17] Fix package name for Ubuntu 16.04 based image. Thanks @dani-garcia! --- docker/Dockerfile.j2 | 4 ++++ docker/amd64/mysql/Dockerfile.alpine | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index dd64be42..42611420 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -140,7 +140,11 @@ ENV USER "root" # Install MySQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ +{% if "musl" in build_stage_base_image %} + libmysqlclient-dev{{ package_arch_prefix }} \ +{% else %} libmariadb-dev{{ package_arch_prefix }} \ +{% endif %} && rm -rf /var/lib/apt/lists/* {% elif "postgresql" in target_file %} diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index a3d11b19..295ef3c6 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -35,7 +35,7 @@ ENV USER "root" # Install MySQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ - libmariadb-dev \ + libmysqlclient-dev \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies From 7a0bb18dcfc3855baa5c4019f159cbfc42f4e8aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Tue, 31 Dec 2019 15:31:01 +0100 Subject: [PATCH 06/17] Make `cargo new` independent of workdir to be exact The muslrust images seem to have a workdir of /volume as opposed to / in the others so doing cargo new like this would create the folder in /volume/app. --- docker/Dockerfile.j2 | 2 +- docker/aarch64/mysql/Dockerfile | 2 +- docker/aarch64/sqlite/Dockerfile | 2 +- docker/amd64/mysql/Dockerfile | 2 +- docker/amd64/mysql/Dockerfile.alpine | 2 +- docker/amd64/postgresql/Dockerfile | 2 +- docker/amd64/postgresql/Dockerfile.alpine | 2 +- docker/amd64/sqlite/Dockerfile | 2 +- docker/amd64/sqlite/Dockerfile.alpine | 2 +- docker/armv6/mysql/Dockerfile | 2 +- docker/armv6/sqlite/Dockerfile | 2 +- docker/armv7/mysql/Dockerfile | 2 +- docker/armv7/sqlite/Dockerfile | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 42611420..c273b4ed 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -156,7 +156,7 @@ RUN apt-get update && apt-get install -y \ {% endif %} # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e7ec2402..e15c25b5 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -65,7 +65,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 0945e573..1cebf6b3 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -59,7 +59,7 @@ ENV CARGO_HOME "/root/.cargo" ENV USER "root" # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index d59c8953..53da03a5 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -44,7 +44,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 295ef3c6..62ad91d7 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -39,7 +39,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index bf1aa2f7..decc2c28 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -44,7 +44,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index 7177698f..a2429058 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -39,7 +39,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 56cf4bee..d874f107 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -38,7 +38,7 @@ ARG DB=sqlite RUN rustup set profile minimal # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 3a1ca323..831eae52 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -33,7 +33,7 @@ RUN rustup set profile minimal ENV USER "root" # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index ceb2ba64..c6920e36 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -65,7 +65,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 638cd983..47b81a5c 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -59,7 +59,7 @@ ENV CARGO_HOME "/root/.cargo" ENV USER "root" # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 74265b45..9efa0c45 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -54,7 +54,7 @@ RUN apt-get update && apt-get install -y \ && rm -rf /var/lib/apt/lists/* # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 32bcb0b2..317dbf1b 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -48,7 +48,7 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libc6-dev:armhf # Creates a dummy project used to grab dependencies -RUN USER=root cargo new --bin app +RUN USER=root cargo new --bin /app WORKDIR /app # Copies over *only* your manifests and build files From 43adcde0946da746aaf99f31012a5c00c517b850 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:38:55 +0100 Subject: [PATCH 07/17] Move `rustup target` before `cargo build`. Thanks to @dani-garcia! Note from @dani-garcia: > I don't think this is doing anything right now because the target is probably > installed already. --- docker/Dockerfile.j2 | 12 +++++++----- docker/aarch64/mysql/Dockerfile | 3 ++- docker/aarch64/sqlite/Dockerfile | 3 ++- docker/amd64/mysql/Dockerfile.alpine | 4 ++-- docker/amd64/postgresql/Dockerfile.alpine | 4 ++-- docker/amd64/sqlite/Dockerfile.alpine | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index c273b4ed..d2d942d9 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -176,6 +176,13 @@ ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" {% endif -%} +{% if "alpine" in target_file %} +RUN rustup target add x86_64-unknown-linux-musl + +{% elif "aarch64" in target_file %} +RUN rustup target add aarch64-unknown-linux-gnu + +{% endif %} # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -189,16 +196,11 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -{% if "alpine" in target_file %} -RUN rustup target add x86_64-unknown-linux-musl - -{% endif %} # Builds again, this time it'll just be # your actual source files being built {% if "amd64" in target_file %} RUN cargo build --features ${DB} --release {% elif "aarch64" in target_file %} -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu {% endif %} diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e15c25b5..4faea593 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -77,6 +77,8 @@ ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +RUN rustup target add aarch64-unknown-linux-gnu + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -92,7 +94,6 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu ######################## RUNTIME IMAGE ######################## diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 1cebf6b3..5eb00a3f 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -71,6 +71,8 @@ ENV CC_aarch64_unknown_linux_gnu="/usr/bin/aarch64-linux-gnu-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/aarch64-linux-gnu" ENV OPENSSL_LIB_DIR="/usr/lib/aarch64-linux-gnu" +RUN rustup target add aarch64-unknown-linux-gnu + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -86,7 +88,6 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built -RUN rustup target add aarch64-unknown-linux-gnu RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu ######################## RUNTIME IMAGE ######################## diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 62ad91d7..56151652 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -47,6 +47,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -60,8 +62,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index a2429058..903a1a30 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -47,6 +47,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -60,8 +62,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 831eae52..221e7e9e 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -41,6 +41,8 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +RUN rustup target add x86_64-unknown-linux-musl + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -54,8 +56,6 @@ COPY . . # Make sure that we actually build the project RUN touch src/main.rs -RUN rustup target add x86_64-unknown-linux-musl - # Builds again, this time it'll just be # your actual source files being built RUN cargo build --features ${DB} --release From 078b21db85b26595aa0f4d880b7f6a60a2c75504 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:45:02 +0100 Subject: [PATCH 08/17] Fix armv6 build, thanks to @dani-garcia for the review! --- docker/Dockerfile.j2 | 5 +++++ docker/armv6/mysql/Dockerfile | 3 +++ docker/armv6/sqlite/Dockerfile | 3 +++ 3 files changed, 11 insertions(+) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index d2d942d9..f4fa1bc5 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -182,6 +182,9 @@ RUN rustup target add x86_64-unknown-linux-musl {% elif "aarch64" in target_file %} RUN rustup target add aarch64-unknown-linux-gnu +{% elif "armv6" in target_file %} +RUN rustup target add arm-unknown-linux-gnueabi + {% endif %} # Builds your dependencies and removes the # dummy project, except the target folder @@ -202,6 +205,8 @@ RUN touch src/main.rs RUN cargo build --features ${DB} --release {% elif "aarch64" in target_file %} RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu +{% elif "armv6" in target_file %} +RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi {% endif %} ######################## RUNTIME IMAGE ######################## diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index c6920e36..7bf2791a 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -77,6 +77,8 @@ ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +RUN rustup target add arm-unknown-linux-gnueabi + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -92,6 +94,7 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built +RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 47b81a5c..a9fe22b5 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -71,6 +71,8 @@ ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +RUN rustup target add arm-unknown-linux-gnueabi + # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies @@ -86,6 +88,7 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built +RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image From 1698b43f9bb6ea3f82db58e956f05dbbc002fe1b Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:49:22 +0100 Subject: [PATCH 09/17] Readd missing cargo setup for armv7. Thanks to @dani-garcia! --- docker/Dockerfile.j2 | 12 ++++++++++++ docker/armv7/mysql/Dockerfile | 11 +++++++++++ docker/armv7/sqlite/Dockerfile | 11 +++++++++++ 3 files changed, 34 insertions(+) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index f4fa1bc5..9308dcbc 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -135,6 +135,18 @@ RUN apt-get update \ ENV CARGO_HOME "/root/.cargo" ENV USER "root" +{% elif "armv7" in target_file %} +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-arm-linux-gnueabihf \ + && mkdir -p ~/.cargo \ + && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ + && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + {% endif %} {% if "mysql" in target_file %} # Install MySQL package diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 9efa0c45..7fca4b57 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -47,6 +47,17 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armhf \ libc6-dev:armhf +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-arm-linux-gnueabihf \ + && mkdir -p ~/.cargo \ + && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ + && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + # Install MySQL package RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 317dbf1b..3e25b6e7 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -47,6 +47,17 @@ RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ libssl-dev:armhf \ libc6-dev:armhf +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ + gcc-arm-linux-gnueabihf \ + && mkdir -p ~/.cargo \ + && echo '[target.armv7-unknown-linux-gnueabihf]' >> ~/.cargo/config \ + && echo 'linker = "arm-linux-gnueabihf-gcc"' >> ~/.cargo/config + +ENV CARGO_HOME "/root/.cargo" +ENV USER "root" + # Creates a dummy project used to grab dependencies RUN USER=root cargo new --bin /app WORKDIR /app From 146525db9195f1be45aff8b7b0abfc0970392c8b Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 15:54:27 +0100 Subject: [PATCH 10/17] Improve Jinja2 template logic a bit --- docker/Dockerfile.j2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 9308dcbc..41e2f4f7 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -86,8 +86,7 @@ RUN rustup set profile minimal {% if "alpine" in target_file %} ENV USER "root" -{% endif %} -{% if "aarch64" in target_file or "armv" in target_file %} +{% elif "aarch64" in target_file or "armv" in target_file %} # Install required build libs for {{ package_arch_name }} architecture. RUN sed 's/^deb/deb-src/' /etc/apt/sources.list > \ /etc/apt/sources.list.d/deb-src.list \ From 446fc3f1f803fd0520167d713451a948ab4cc0fb Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 16:20:04 +0100 Subject: [PATCH 11/17] Set build time options for dpkg and reproducible builds Ref: https://github.com/moby/moby/issues/4032 Ref: https://sweetcode.io/using-docker-reproducible-build-environments/ Ref: https://github.com/hashbang/aosp-build/blob/master/config/container/Dockerfile --- docker/Dockerfile.j2 | 18 ++++++++++++++---- docker/aarch64/mysql/Dockerfile | 18 ++++++++++++++---- docker/aarch64/sqlite/Dockerfile | 18 ++++++++++++++---- docker/amd64/mysql/Dockerfile | 18 ++++++++++++++---- docker/amd64/mysql/Dockerfile.alpine | 6 ++++++ docker/amd64/postgresql/Dockerfile | 18 ++++++++++++++---- docker/amd64/postgresql/Dockerfile.alpine | 6 ++++++ docker/amd64/sqlite/Dockerfile | 18 ++++++++++++++---- docker/amd64/sqlite/Dockerfile.alpine | 6 ++++++ docker/armv6/mysql/Dockerfile | 18 ++++++++++++++---- docker/armv6/sqlite/Dockerfile | 18 ++++++++++++++---- docker/armv7/mysql/Dockerfile | 18 ++++++++++++++---- docker/armv7/sqlite/Dockerfile | 18 ++++++++++++++---- 13 files changed, 158 insertions(+), 40 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 41e2f4f7..4a604085 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -37,10 +37,14 @@ RUN apk add --no-cache --upgrade \ curl \ tar {% else %} -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -80,6 +84,12 @@ ARG DB=mysql ARG DB=postgresql {% endif %} +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index 4faea593..5dfac4a5 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set mysql backend ARG DB=mysql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 5eb00a3f..fa7cd7d6 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 53da03a5..d2d304ff 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set mysql backend ARG DB=mysql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index 56151652..b20754b2 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -27,6 +27,12 @@ FROM clux/muslrust:nightly-2019-12-19 as build # set mysql backend ARG DB=mysql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index decc2c28..532f6fdf 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set postgresql backend ARG DB=postgresql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index 903a1a30..cef25d1c 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -27,6 +27,12 @@ FROM clux/muslrust:nightly-2019-12-19 as build # set postgresql backend ARG DB=postgresql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index d874f107..ec5b8496 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 221e7e9e..1b08bd21 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -27,6 +27,12 @@ FROM clux/muslrust:nightly-2019-12-19 as build # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index 7bf2791a..11426179 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set mysql backend ARG DB=mysql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index a9fe22b5..6c713221 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 7fca4b57..5b8dc6c1 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set mysql backend ARG DB=mysql +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 3e25b6e7..15ec9a2b 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -8,10 +8,14 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" -ENV DEBIAN_FRONTEND=noninteractive \ - LANG=C.UTF-8 \ - TZ=UTC \ - TERM=xterm-256color + +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + +RUN echo $TERM RUN apt update -y \ && apt install -y \ @@ -34,6 +38,12 @@ FROM rust:1.40 as build # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite +# Build time options to avoid dpkg warnings and help with reproducible builds. +ARG DEBIAN_FRONTEND=noninteractive +ARG LANG=C.UTF-8 +ARG TZ=UTC +ARG TERM=xterm-256color + # Don't download rust docs RUN rustup set profile minimal From f6a4a2127b64201eac48dbb59e5beb4529d11d04 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 16:24:49 +0100 Subject: [PATCH 12/17] Remove duplicate empty lines in generated Dockerfiles Checked with: ```Shell find . -type f -print0 | xargs -0 pcregrep -M '\n\n\n' ``` --- docker/Dockerfile.j2 | 7 ++++--- docker/aarch64/mysql/Dockerfile | 1 - docker/aarch64/sqlite/Dockerfile | 1 - docker/amd64/mysql/Dockerfile | 2 -- docker/amd64/mysql/Dockerfile.alpine | 1 - docker/amd64/postgresql/Dockerfile | 2 -- docker/amd64/postgresql/Dockerfile.alpine | 1 - docker/amd64/sqlite/Dockerfile | 2 -- docker/amd64/sqlite/Dockerfile.alpine | 1 - docker/armv6/mysql/Dockerfile | 1 - docker/armv6/sqlite/Dockerfile | 1 - docker/armv7/mysql/Dockerfile | 1 - docker/armv7/sqlite/Dockerfile | 1 - 13 files changed, 4 insertions(+), 18 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 4a604085..54c3e8b8 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -37,7 +37,6 @@ RUN apk add --no-cache --upgrade \ curl \ tar {% else %} - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 @@ -76,14 +75,16 @@ FROM {{ build_stage_base_image }} as build {% if "sqlite" in target_file %} # set sqlite as default for DB ARG for backward compatibility ARG DB=sqlite + {% elif "mysql" in target_file %} # set mysql backend ARG DB=mysql + {% elif "postgresql" in target_file %} # set postgresql backend ARG DB=postgresql -{% endif %} +{% endif %} # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 @@ -244,8 +245,8 @@ ENV SSL_CERT_DIR=/etc/ssl/certs {% if "amd64" not in target_file %} RUN [ "cross-build-start" ] -{% endif %} +{% endif %} # Install needed libraries {% if "alpine" in runtime_stage_base_image %} RUN apk add --no-cache \ diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index 5dfac4a5..c1bf4ad2 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index fa7cd7d6..2424c67b 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index d2d304ff..4368a374 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 @@ -88,7 +87,6 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 - # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index b20754b2..b09b422a 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -82,7 +82,6 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs - # Install needed libraries RUN apk add --no-cache \ openssl \ diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index 532f6fdf..0ba087c7 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 @@ -88,7 +87,6 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 - # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index cef25d1c..0a298baa 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -82,7 +82,6 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs - # Install needed libraries RUN apk add --no-cache \ openssl \ diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index ec5b8496..f295fad0 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 @@ -82,7 +81,6 @@ ENV ROCKET_ENV "staging" ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 - # Install needed libraries RUN apt-get update && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 1b08bd21..269a3dc4 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -76,7 +76,6 @@ ENV ROCKET_PORT=80 ENV ROCKET_WORKERS=10 ENV SSL_CERT_DIR=/etc/ssl/certs - # Install needed libraries RUN apk add --no-cache \ openssl \ diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index 11426179..a89e49b7 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 6c713221..3a04b439 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 5b8dc6c1..cf9e25c1 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 15ec9a2b..33b1bba4 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -8,7 +8,6 @@ ENV VAULT_VERSION "v2.12.0b" ENV URL "https://github.com/dani-garcia/bw_web_builds/releases/download/$VAULT_VERSION/bw_web_$VAULT_VERSION.tar.gz" - # Build time options to avoid dpkg warnings and help with reproducible builds. ARG DEBIAN_FRONTEND=noninteractive ARG LANG=C.UTF-8 From f8e49ea3f42e50fbdcc764e99d833bc78291d72f Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Tue, 31 Dec 2019 16:40:15 +0100 Subject: [PATCH 13/17] Use apt-get instead of apt in Dockerfiles, also --no-install-recommends apt is intended for humans, not scripts. --no-install-recommends improves build time by avoiding to install unneeded packages. --- docker/Dockerfile.j2 | 5 +++-- docker/aarch64/mysql/Dockerfile | 5 +++-- docker/aarch64/sqlite/Dockerfile | 5 +++-- docker/amd64/mysql/Dockerfile | 5 +++-- docker/amd64/postgresql/Dockerfile | 5 +++-- docker/amd64/sqlite/Dockerfile | 5 +++-- docker/armv6/mysql/Dockerfile | 5 +++-- docker/armv6/sqlite/Dockerfile | 5 +++-- docker/armv7/mysql/Dockerfile | 5 +++-- docker/armv7/sqlite/Dockerfile | 5 +++-- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 54c3e8b8..5fde7dcd 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -45,8 +45,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar {% endif %} diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index c1bf4ad2..cea326db 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 2424c67b..88f44b6f 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 4368a374..63ce0407 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index 0ba087c7..a6a8f7f5 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index f295fad0..a1bb5e5c 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index a89e49b7..b249e09e 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 3a04b439..4b163a01 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index cf9e25c1..860bf704 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 33b1bba4..52e49f6d 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -16,8 +16,9 @@ ARG TERM=xterm-256color RUN echo $TERM -RUN apt update -y \ - && apt install -y \ +RUN apt-get update \ + && apt-get install -y \ + --no-install-recommends \ curl \ tar From f6761ac30efa13faadda959306f52b23679d58cb Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Wed, 1 Jan 2020 15:17:33 +0100 Subject: [PATCH 14/17] Remove debugging echo statement from Dockerfiles --- docker/Dockerfile.j2 | 2 -- docker/aarch64/mysql/Dockerfile | 2 -- docker/aarch64/sqlite/Dockerfile | 2 -- docker/amd64/mysql/Dockerfile | 2 -- docker/amd64/postgresql/Dockerfile | 2 -- docker/amd64/sqlite/Dockerfile | 2 -- docker/armv6/mysql/Dockerfile | 2 -- docker/armv6/sqlite/Dockerfile | 2 -- docker/armv7/mysql/Dockerfile | 2 -- docker/armv7/sqlite/Dockerfile | 2 -- 10 files changed, 20 deletions(-) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 5fde7dcd..72873e3b 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -43,8 +43,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index cea326db..e7060aa5 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index 88f44b6f..c94fafa9 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 63ce0407..4bd7c4a9 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index a6a8f7f5..5d781ab9 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index a1bb5e5c..047196c1 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index b249e09e..a97aafe0 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index 4b163a01..b93f6765 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 860bf704..f17e9c63 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 52e49f6d..67d3a29a 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -14,8 +14,6 @@ ARG LANG=C.UTF-8 ARG TZ=UTC ARG TERM=xterm-256color -RUN echo $TERM - RUN apt-get update \ && apt-get install -y \ --no-install-recommends \ From def858854b66f4fdcafbccaebca9435e343839c4 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Wed, 1 Jan 2020 15:44:03 +0100 Subject: [PATCH 15/17] Readd missing cargo build for armv7. Thanks to @dani-garcia! --- docker/Dockerfile.j2 | 2 ++ docker/armv7/mysql/Dockerfile | 1 + docker/armv7/sqlite/Dockerfile | 1 + 3 files changed, 4 insertions(+) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 72873e3b..03322d6d 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -228,6 +228,8 @@ RUN cargo build --features ${DB} --release RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu {% elif "armv6" in target_file %} RUN cargo build --features ${DB} --release --target=arm-unknown-linux-gnueabi +{% elif "armv7" in target_file %} +RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf {% endif %} ######################## RUNTIME IMAGE ######################## diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index f17e9c63..77430ca3 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -96,6 +96,7 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built +RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 67d3a29a..4cd38412 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -90,6 +90,7 @@ RUN touch src/main.rs # Builds again, this time it'll just be # your actual source files being built +RUN cargo build --features ${DB} --release --target=armv7-unknown-linux-gnueabihf ######################## RUNTIME IMAGE ######################## # Create a new stage with a minimal image From 402c857d17ef54bfefec9ddd6e63e91090bcf781 Mon Sep 17 00:00:00 2001 From: Robin Schneider Date: Wed, 1 Jan 2020 15:47:18 +0100 Subject: [PATCH 16/17] Add hint to Dockerfile's that they are generated --- docker/Dockerfile.j2 | 3 +++ docker/aarch64/mysql/Dockerfile | 3 +++ docker/aarch64/sqlite/Dockerfile | 3 +++ docker/amd64/mysql/Dockerfile | 3 +++ docker/amd64/mysql/Dockerfile.alpine | 3 +++ docker/amd64/postgresql/Dockerfile | 3 +++ docker/amd64/postgresql/Dockerfile.alpine | 3 +++ docker/amd64/sqlite/Dockerfile | 3 +++ docker/amd64/sqlite/Dockerfile.alpine | 3 +++ docker/armv6/mysql/Dockerfile | 3 +++ docker/armv6/sqlite/Dockerfile | 3 +++ docker/armv7/mysql/Dockerfile | 3 +++ docker/armv7/sqlite/Dockerfile | 3 +++ 13 files changed, 39 insertions(+) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index 03322d6d..f152b9de 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -1,3 +1,6 @@ +{{ "# This file was generated using a Jinja2 template." }} +{{ "# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's." }} + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/aarch64/mysql/Dockerfile b/docker/aarch64/mysql/Dockerfile index e7060aa5..e1408b7b 100644 --- a/docker/aarch64/mysql/Dockerfile +++ b/docker/aarch64/mysql/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/aarch64/sqlite/Dockerfile b/docker/aarch64/sqlite/Dockerfile index c94fafa9..1cd1649e 100644 --- a/docker/aarch64/sqlite/Dockerfile +++ b/docker/aarch64/sqlite/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/mysql/Dockerfile b/docker/amd64/mysql/Dockerfile index 4bd7c4a9..708c8ebc 100644 --- a/docker/amd64/mysql/Dockerfile +++ b/docker/amd64/mysql/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/mysql/Dockerfile.alpine b/docker/amd64/mysql/Dockerfile.alpine index b09b422a..98f0dcab 100644 --- a/docker/amd64/mysql/Dockerfile.alpine +++ b/docker/amd64/mysql/Dockerfile.alpine @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/postgresql/Dockerfile b/docker/amd64/postgresql/Dockerfile index 5d781ab9..d7132e8b 100644 --- a/docker/amd64/postgresql/Dockerfile +++ b/docker/amd64/postgresql/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/postgresql/Dockerfile.alpine b/docker/amd64/postgresql/Dockerfile.alpine index 0a298baa..860240dd 100644 --- a/docker/amd64/postgresql/Dockerfile.alpine +++ b/docker/amd64/postgresql/Dockerfile.alpine @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/sqlite/Dockerfile b/docker/amd64/sqlite/Dockerfile index 047196c1..23230ddb 100644 --- a/docker/amd64/sqlite/Dockerfile +++ b/docker/amd64/sqlite/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/amd64/sqlite/Dockerfile.alpine b/docker/amd64/sqlite/Dockerfile.alpine index 269a3dc4..d201a3ba 100644 --- a/docker/amd64/sqlite/Dockerfile.alpine +++ b/docker/amd64/sqlite/Dockerfile.alpine @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/armv6/mysql/Dockerfile b/docker/armv6/mysql/Dockerfile index a97aafe0..ff5689b8 100644 --- a/docker/armv6/mysql/Dockerfile +++ b/docker/armv6/mysql/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/armv6/sqlite/Dockerfile b/docker/armv6/sqlite/Dockerfile index b93f6765..b9bc438d 100644 --- a/docker/armv6/sqlite/Dockerfile +++ b/docker/armv6/sqlite/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index 77430ca3..b5cad1d4 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 4cd38412..77c82efe 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -1,3 +1,6 @@ +# This file was generated using a Jinja2 template. +# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's. + # Using multistage build: # https://docs.docker.com/develop/develop-images/multistage-build/ # https://whitfin.io/speeding-up-rust-docker-builds/ From a3b30ed65ab68f7e9afbe6ba0cbcf92b0946a670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa?= Date: Sun, 5 Jan 2020 22:41:58 +0100 Subject: [PATCH 17/17] Add missing target armv7 and cross compile envs --- docker/Dockerfile.j2 | 7 +++++++ docker/armv7/mysql/Dockerfile | 5 +++++ docker/armv7/sqlite/Dockerfile | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/docker/Dockerfile.j2 b/docker/Dockerfile.j2 index f152b9de..6fac7634 100644 --- a/docker/Dockerfile.j2 +++ b/docker/Dockerfile.j2 @@ -198,6 +198,11 @@ ENV CC_arm_unknown_linux_gnueabi="/usr/bin/arm-linux-gnueabi-gcc" ENV CROSS_COMPILE="1" ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabi" ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabi" +{% elif "armv7" in target_file %} +ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" +ENV CROSS_COMPILE="1" +ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabihf" +ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabihf" {% endif -%} {% if "alpine" in target_file %} @@ -209,6 +214,8 @@ RUN rustup target add aarch64-unknown-linux-gnu {% elif "armv6" in target_file %} RUN rustup target add arm-unknown-linux-gnueabi +{% elif "armv7" in target_file %} +RUN rustup target add armv7-unknown-linux-gnueabihf {% endif %} # Builds your dependencies and removes the # dummy project, except the target folder diff --git a/docker/armv7/mysql/Dockerfile b/docker/armv7/mysql/Dockerfile index b5cad1d4..5528830b 100644 --- a/docker/armv7/mysql/Dockerfile +++ b/docker/armv7/mysql/Dockerfile @@ -84,6 +84,11 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" +ENV CROSS_COMPILE="1" +ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabihf" +ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabihf" +RUN rustup target add armv7-unknown-linux-gnueabihf # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies diff --git a/docker/armv7/sqlite/Dockerfile b/docker/armv7/sqlite/Dockerfile index 77c82efe..90ac162b 100644 --- a/docker/armv7/sqlite/Dockerfile +++ b/docker/armv7/sqlite/Dockerfile @@ -78,6 +78,11 @@ COPY ./Cargo.* ./ COPY ./rust-toolchain ./rust-toolchain COPY ./build.rs ./build.rs +ENV CC_armv7_unknown_linux_gnueabihf="/usr/bin/arm-linux-gnueabihf-gcc" +ENV CROSS_COMPILE="1" +ENV OPENSSL_INCLUDE_DIR="/usr/include/arm-linux-gnueabihf" +ENV OPENSSL_LIB_DIR="/usr/lib/arm-linux-gnueabihf" +RUN rustup target add armv7-unknown-linux-gnueabihf # Builds your dependencies and removes the # dummy project, except the target folder # This folder contains the compiled dependencies