diff --git a/crates/bws/.dockerignore b/crates/bws/.dockerignore index 3f459493b..0a5936176 100644 --- a/crates/bws/.dockerignore +++ b/crates/bws/.dockerignore @@ -1,51 +1,4 @@ -/target -.DS_Store -.pytest_cache +* +!crates/* +!Cargo.toml -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -build/ -bld/ -[Bb]in/ -[Oo]bj/ - -# Editor directories and files -.idea -xcuserdata/ - -# Added by cargo -# -# already existing elements were commented out - -#/target -node_modules/ -clients/python/env/ - -# Third party license -THIRDPARTY.html - -# Node.js addon binary file, for the current running operating system. -crates/bitwarden-napi/sdk-napi.*.node - -# Complied TypeScript client -crates/bitwarden-napi/dist - -# Uniffi -languages/swift/BitwardenFFI.xcframework -languages/swift/tmp -languages/swift/.build -languages/swift/.swiftpm -languages/kotlin/sdk/src/main/java/com/bitwarden/sdk/bitwarden_uniffi.kt -languages/kotlin/sdk/src/main/java/com/bitwarden/core/bitwarden.kt - -# Schemas -support/schemas -crates/bitwarden-napi/src-ts/bitwarden_client/schemas.ts -languages/csharp/Bitwarden.Sdk/schemas.cs -languages/js_webassembly/bitwarden_client/schemas.ts -languages/python/BitwardenClient/schemas.py diff --git a/crates/bws/Dockerfile b/crates/bws/Dockerfile index 05cc88571..d75494648 100644 --- a/crates/bws/Dockerfile +++ b/crates/bws/Dockerfile @@ -1,15 +1,34 @@ -ARG ARCH= -FROM ${ARCH}rust:1.73 as builder -RUN apt-get update && \ - apt-get install --no-install-recommends -y \ +############################################### +# Build stage # +############################################### +FROM --platform=$BUILDPLATFORM rust:1.73 AS build + +# Docker buildx supplies the value for this arg +ARG TARGETPLATFORM + +RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates \ && rm -rf /var/lib/apt/lists/* -COPY ../../ /app + +# Copy required project files +COPY . /app + +# Build project WORKDIR /app/crates/bws RUN cargo build --release -FROM ${ARCH}debian:bookworm-slim as runner + +############################################### +# App stage # +############################################### +FROM debian:bookworm-slim + +ARG TARGETPLATFORM +LABEL com.bitwarden.product="bitwarden" + +# Copy built project from the build stage WORKDIR /usr/local/bin -COPY --from=builder /app/target/release/bws . -COPY --from=builder /etc/ssl/certs /etc/ssl/certs +COPY --from=build /app/target/release/bws . +COPY --from=build /etc/ssl/certs /etc/ssl/certs ENTRYPOINT ["bws"] +