mirror of
https://github.com/ViViDboarder/bitwarden_rs.git
synced 2024-11-22 05:06:37 +00:00
Fix cross platform build support, thanks to @dani-garcia for the review
This commit is contained in:
parent
8280d200ea
commit
43aa75dc89
@ -2,33 +2,37 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### 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 %}
|
{% 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 = "" %}
|
{% set package_arch_name = "" %}
|
||||||
{% elif "amd64" in target_file %}
|
{% elif "amd64" in target_file %}
|
||||||
{% set preferred_base_image = "debian:buster-slim" %}
|
{% set runtime_stage_base_image = "debian:buster-slim" %}
|
||||||
{% set package_arch_name = "" %}
|
{% set package_arch_name = "" %}
|
||||||
{% elif "aarch64" in target_file %}
|
{% 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" %}
|
{% set package_arch_name = "arm64" %}
|
||||||
{% elif "armv6" in target_file %}
|
{% 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" %}
|
{% set package_arch_name = "armel" %}
|
||||||
{% elif "armv7" in target_file %}
|
{% 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" %}
|
{% set package_arch_name = "armhf" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set package_arch_prefix = ":" + package_arch_name %}
|
{% set package_arch_prefix = ":" + package_arch_name %}
|
||||||
{% if package_arch_name == "" %}
|
{% if package_arch_name == "" %}
|
||||||
{% set package_arch_prefix = "" %}
|
{% set package_arch_prefix = "" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
FROM {{ preferred_base_image }} as vault
|
FROM {{ vault_stage_base_image }} as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
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 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 \
|
RUN apk add --no-cache --upgrade \
|
||||||
curl \
|
curl \
|
||||||
tar
|
tar
|
||||||
@ -47,7 +51,7 @@ RUN apt update -y \
|
|||||||
RUN mkdir /web-vault
|
RUN mkdir /web-vault
|
||||||
WORKDIR /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"]
|
SHELL ["/bin/ash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"]
|
||||||
{% else %}
|
{% else %}
|
||||||
SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"]
|
SHELL ["/bin/bash", "-o", "nounset", "-o", "pipefail", "-o", "errexit", "-c"]
|
||||||
@ -57,14 +61,13 @@ RUN curl -L $URL | tar xz
|
|||||||
RUN ls
|
RUN ls
|
||||||
|
|
||||||
########################## BUILD IMAGE ##########################
|
########################## BUILD IMAGE ##########################
|
||||||
{% if "alpine" in target_file %}
|
{% if "musl" in build_stage_base_image %}
|
||||||
# Musl build image for statically compiled binary
|
# Musl build image for statically compiled binary
|
||||||
FROM clux/muslrust:nightly-2019-12-19 as build
|
|
||||||
{% else %}
|
{% else %}
|
||||||
# We need to use the Rust build image, because
|
# We need to use the Rust build image, because
|
||||||
# we need the Rust compiler and Cargo tooling
|
# we need the Rust compiler and Cargo tooling
|
||||||
FROM rust:1.40 as build
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
FROM {{ build_stage_base_image }} as build
|
||||||
|
|
||||||
{% if "sqlite" in target_file %}
|
{% if "sqlite" in target_file %}
|
||||||
# set sqlite as default for DB ARG for backward compatibility
|
# 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 ########################
|
######################## RUNTIME IMAGE ########################
|
||||||
# Create a new stage with a minimal image
|
# Create a new stage with a minimal image
|
||||||
# because we already have a binary built
|
# because we already have a binary built
|
||||||
FROM {{ preferred_base_image }}
|
FROM {{ runtime_stage_base_image }}
|
||||||
|
|
||||||
ENV ROCKET_ENV "staging"
|
ENV ROCKET_ENV "staging"
|
||||||
ENV ROCKET_PORT=80
|
ENV ROCKET_PORT=80
|
||||||
ENV ROCKET_WORKERS=10
|
ENV ROCKET_WORKERS=10
|
||||||
{% if "alpine" in target_file %}
|
{% if "alpine" in runtime_stage_base_image %}
|
||||||
ENV SSL_CERT_DIR=/etc/ssl/certs
|
ENV SSL_CERT_DIR=/etc/ssl/certs
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@ -213,7 +216,7 @@ RUN [ "cross-build-start" ]
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Install needed libraries
|
# Install needed libraries
|
||||||
{% if "alpine" in target_file %}
|
{% if "alpine" in runtime_stage_base_image %}
|
||||||
RUN apk add --no-cache \
|
RUN apk add --no-cache \
|
||||||
openssl \
|
openssl \
|
||||||
curl \
|
curl \
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/aarch64-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/aarch64-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM debian:buster-slim as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM debian:buster-slim as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM debian:buster-slim as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/rpi-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/rpi-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/armv7hf-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# https://docs.docker.com/develop/develop-images/multistage-build/
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||||||
# https://whitfin.io/speeding-up-rust-docker-builds/
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||||||
####################### VAULT BUILD IMAGE #######################
|
####################### VAULT BUILD IMAGE #######################
|
||||||
FROM balenalib/armv7hf-debian:buster as vault
|
FROM rust:1.40 as vault
|
||||||
|
|
||||||
ENV VAULT_VERSION "v2.12.0b"
|
ENV VAULT_VERSION "v2.12.0b"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user