5
0
Fork 0

chore: adding back Dockerfile

master
Sudharshan S. 2019-03-23 22:47:40 +08:00
parent d673f67be0
commit 98566ca24f
Signed by: sudharshan
GPG Key ID: C861C97AAF3D9559
1 changed files with 40 additions and 0 deletions

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
# FROM rust:1.32 as build
FROM alpine:3.9 AS build
RUN apk add --no-cache gcc musl-dev
RUN apk add --no-cache rust cargo
# RUN rustup target add x86_64-unknown-linux-musl
# Create new empty shell project
RUN USER=root cargo new --bin app
WORKDIR /app
# Copy over Cargo.toml
COPY ./Cargo.toml ./Cargo.toml
# Change target env
ENV RUSTFLAGS="-C target-cpu=native"
# ENV RUSTFLAGS="-C target-cpu=x86_64_alpine-linux-musl"
# Run build step to cache dependencies
RUN cargo build --release
RUN rm src/*.rs
# Copy over src files
COPY ./src/main.rs ./src/main.rs
# Build for release
RUN rm ./target/release/deps/backend_auth*
RUN cargo build --release
# Copy over .env
COPY ./.env ./.env
FROM alpine:3.9
RUN apk add --no-cache gcc
COPY --from=build /app/target/release .
COPY --from=build /app/.env .env
ENTRYPOINT ["./backend-auth"]