From 346c7630c913bcf95286130e64a1594d8a4235fb Mon Sep 17 00:00:00 2001
From: Miroslav Prasil <miroslav@prasil.info>
Date: Fri, 17 Aug 2018 14:30:25 +0100
Subject: [PATCH] Initial implementation of musl build on top of Alpine

---
 Dockerfile | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 860e76c7..8e7e43d1 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -25,19 +25,11 @@ RUN npm run dist \
     && mv build /web-vault
 
 ########################## BUILD IMAGE  ##########################
-# We need to use the Rust build image, because
-# we need the Rust compiler and Cargo tooling
-FROM rust as build
-
-# Using bundled SQLite, no need to install it
-# RUN apt-get update && apt-get install -y\
-#    sqlite3\
-#    --no-install-recommends\
-# && rm -rf /var/lib/apt/lists/*
+# Musl build image for statically compiled binary
+FROM clux/muslrust:nightly-2018-06-26 as build
 
 # Creates a dummy project used to grab dependencies
-RUN USER=root cargo new --bin app
-WORKDIR /app
+RUN USER=root cargo init --bin
 
 # Copies over *only* your manifests and vendored dependencies
 COPY ./Cargo.* ./
@@ -61,17 +53,15 @@ RUN cargo build --release
 ######################## RUNTIME IMAGE  ########################
 # Create a new stage with a minimal image
 # because we already have a binary built
-FROM debian:stretch-slim
+FROM alpine:3.8
 
 ENV ROCKET_ENV "staging"
 ENV ROCKET_WORKERS=10
 
 # Install needed libraries
-RUN apt-get update && apt-get install -y\
+RUN apk add \
     openssl\
-    ca-certificates\
-    --no-install-recommends\
- && rm -rf /var/lib/apt/lists/*
+    ca-certificates
 
 RUN mkdir /data
 VOLUME /data
@@ -82,7 +72,7 @@ EXPOSE 80
 COPY .env .
 COPY Rocket.toml .
 COPY --from=vault /web-vault ./web-vault
-COPY --from=build app/target/release/bitwarden_rs .
+COPY --from=build /volume/target/x86_64-unknown-linux-musl/release/bitwarden_rs .
 
 # Configures the startup!
 CMD ./bitwarden_rs
-- 
GitLab