Initial implementation of musl build on top of Alpine

This commit is contained in:
Miroslav Prasil 2018-08-17 14:30:25 +01:00
parent 1c57c9d8e0
commit 346c7630c9
1 changed files with 7 additions and 17 deletions

View File

@ -25,19 +25,11 @@ RUN npm run dist \
&& mv build /web-vault && mv build /web-vault
########################## BUILD IMAGE ########################## ########################## BUILD IMAGE ##########################
# We need to use the Rust build image, because # Musl build image for statically compiled binary
# we need the Rust compiler and Cargo tooling FROM clux/muslrust:nightly-2018-06-26 as build
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/*
# Creates a dummy project used to grab dependencies # Creates a dummy project used to grab dependencies
RUN USER=root cargo new --bin app RUN USER=root cargo init --bin
WORKDIR /app
# Copies over *only* your manifests and vendored dependencies # Copies over *only* your manifests and vendored dependencies
COPY ./Cargo.* ./ COPY ./Cargo.* ./
@ -61,17 +53,15 @@ RUN cargo build --release
######################## 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 debian:stretch-slim FROM alpine:3.8
ENV ROCKET_ENV "staging" ENV ROCKET_ENV "staging"
ENV ROCKET_WORKERS=10 ENV ROCKET_WORKERS=10
# Install needed libraries # Install needed libraries
RUN apt-get update && apt-get install -y\ RUN apk add \
openssl\ openssl\
ca-certificates\ ca-certificates
--no-install-recommends\
&& rm -rf /var/lib/apt/lists/*
RUN mkdir /data RUN mkdir /data
VOLUME /data VOLUME /data
@ -82,7 +72,7 @@ EXPOSE 80
COPY .env . COPY .env .
COPY Rocket.toml . COPY Rocket.toml .
COPY --from=vault /web-vault ./web-vault 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! # Configures the startup!
CMD ./bitwarden_rs CMD ./bitwarden_rs