Add Dockerfile

This commit is contained in:
2022-02-18 23:18:41 +01:00
parent e0d0bef292
commit 06e12c186a
2 changed files with 51 additions and 5 deletions

40
Dockerfile Normal file
View File

@ -0,0 +1,40 @@
##################
### BASE STAGE ###
##################
FROM rust:1.57 as base
# Install build dependencies
RUN cargo install --locked trunk strip_cargo_version
RUN rustup target add wasm32-unknown-unknown
WORKDIR /app
RUN mkdir frontend backend common
###########################
### STRIP-VERSION STAGE ###
###########################
FROM base AS strip-version
COPY Cargo.lock Cargo.toml ./
RUN strip_cargo_version
###################
### BUILD STAGE ###
###################
FROM base AS build
RUN cargo init --lib .
COPY --from=strip-version /app/Cargo.toml /app/Cargo.lock /app/
RUN cargo build --release --target wasm32-unknown-unknown
COPY . .
RUN trunk build --release
########################
### PRODUCTION STAGE ###
########################
FROM nginx:alpine
COPY --from=base /app/dist/* /usr/share/nginx/html/