You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
4.2 KiB
129 lines
4.2 KiB
5 years ago
|
# This file was generated using a Jinja2 template.
|
||
|
# Please make your changes in `Dockerfile.j2` and then `make` the individual Dockerfile's.
|
||
|
|
||
5 years ago
|
# Using multistage build:
|
||
6 years ago
|
# https://docs.docker.com/develop/develop-images/multistage-build/
|
||
|
# https://whitfin.io/speeding-up-rust-docker-builds/
|
||
|
####################### VAULT BUILD IMAGE #######################
|
||
|
|
||
5 years ago
|
# This hash is extracted from the docker web-vault builds and it's prefered over a simple tag because it's immutable.
|
||
|
# It can be viewed in multiple ways:
|
||
|
# - From the https://hub.docker.com/repository/docker/bitwardenrs/web-vault/tags page, click the tag name and the digest should be there.
|
||
|
# - From the console, with the following commands:
|
||
5 years ago
|
# docker pull bitwardenrs/web-vault:v2.15.1
|
||
|
# docker image inspect --format "{{.RepoDigests}}" bitwardenrs/web-vault:v2.15.1
|
||
5 years ago
|
#
|
||
5 years ago
|
# - To do the opposite, and get the tag from the hash, you can do:
|
||
5 years ago
|
# docker image inspect --format "{{.RepoTags}}" bitwardenrs/web-vault@sha256:afba1e3bded09dc0a6a0dbacb3363ac33b6f122b4b26d3682cafb9115bdf785c
|
||
|
FROM bitwardenrs/web-vault@sha256:afba1e3bded09dc0a6a0dbacb3363ac33b6f122b4b26d3682cafb9115bdf785c as vault
|
||
6 years ago
|
|
||
|
########################## BUILD IMAGE ##########################
|
||
|
# We need to use the Rust build image, because
|
||
|
# we need the Rust compiler and Cargo tooling
|
||
5 years ago
|
FROM rust:1.40 as build
|
||
6 years ago
|
|
||
5 years ago
|
# set sqlite as default for DB ARG for backward compatibility
|
||
6 years ago
|
ARG DB=sqlite
|
||
|
|
||
5 years ago
|
# Build time options to avoid dpkg warnings and help with reproducible builds.
|
||
5 years ago
|
ENV DEBIAN_FRONTEND=noninteractive LANG=C.UTF-8 TZ=UTC TERM=xterm-256color
|
||
5 years ago
|
|
||
5 years ago
|
# Don't download rust docs
|
||
|
RUN rustup set profile minimal
|
||
|
|
||
5 years ago
|
# 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
|
||
|
|
||
6 years ago
|
RUN apt-get update \
|
||
|
&& apt-get install -y \
|
||
6 years ago
|
--no-install-recommends \
|
||
6 years ago
|
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"
|
||
|
|
||
5 years ago
|
# Creates a dummy project used to grab dependencies
|
||
5 years ago
|
RUN USER=root cargo new --bin /app
|
||
6 years ago
|
WORKDIR /app
|
||
|
|
||
5 years ago
|
# Copies over *only* your manifests and build files
|
||
|
COPY ./Cargo.* ./
|
||
|
COPY ./rust-toolchain ./rust-toolchain
|
||
|
COPY ./build.rs ./build.rs
|
||
|
|
||
6 years ago
|
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"
|
||
5 years ago
|
RUN rustup target add aarch64-unknown-linux-gnu
|
||
|
|
||
5 years ago
|
# 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
|
||
6 years ago
|
|
||
|
# Copies the complete project
|
||
|
# To avoid copying unneeded files, use .dockerignore
|
||
|
COPY . .
|
||
|
|
||
5 years ago
|
# 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
|
||
5 years ago
|
RUN cargo build --features ${DB} --release --target=aarch64-unknown-linux-gnu
|
||
6 years ago
|
|
||
|
######################## RUNTIME IMAGE ########################
|
||
|
# Create a new stage with a minimal image
|
||
|
# because we already have a binary built
|
||
5 years ago
|
FROM balenalib/aarch64-debian:buster
|
||
6 years ago
|
|
||
|
ENV ROCKET_ENV "staging"
|
||
6 years ago
|
ENV ROCKET_PORT=80
|
||
6 years ago
|
ENV ROCKET_WORKERS=10
|
||
|
|
||
|
RUN [ "cross-build-start" ]
|
||
|
|
||
|
# Install needed libraries
|
||
6 years ago
|
RUN apt-get update && apt-get install -y \
|
||
|
--no-install-recommends \
|
||
|
openssl \
|
||
|
ca-certificates \
|
||
5 years ago
|
curl \
|
||
5 years ago
|
sqlite3 \
|
||
5 years ago
|
&& rm -rf /var/lib/apt/lists/*
|
||
6 years ago
|
|
||
|
RUN mkdir /data
|
||
|
|
||
5 years ago
|
RUN [ "cross-build-end" ]
|
||
6 years ago
|
|
||
|
VOLUME /data
|
||
|
EXPOSE 80
|
||
5 years ago
|
EXPOSE 3012
|
||
6 years ago
|
|
||
6 years ago
|
# Copies the files from the context (Rocket.toml file and web-vault)
|
||
6 years ago
|
# and the binary from the "build" stage to the current stage
|
||
|
COPY Rocket.toml .
|
||
|
COPY --from=vault /web-vault ./web-vault
|
||
|
COPY --from=build /app/target/aarch64-unknown-linux-gnu/release/bitwarden_rs .
|
||
|
|
||
5 years ago
|
COPY docker/healthcheck.sh /healthcheck.sh
|
||
5 years ago
|
COPY docker/start.sh /start.sh
|
||
5 years ago
|
|
||
5 years ago
|
HEALTHCHECK --interval=60s --timeout=10s CMD ["/healthcheck.sh"]
|
||
5 years ago
|
|
||
6 years ago
|
# Configures the startup!
|
||
5 years ago
|
WORKDIR /
|
||
5 years ago
|
CMD ["/start.sh"]
|