From 08dbd3d4e72f6e915004b1e42c0ca7d81f879b7f Mon Sep 17 00:00:00 2001 From: monsterkrampe Date: Wed, 31 Aug 2022 15:59:42 +0200 Subject: [PATCH] Add Dockerfile as example for server with frontend --- .dockerignore | 4 ++++ Dockerfile | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4149586 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +frontend/node_modules +frontend/.parcel-cache +target/debug + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..df7a38f --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +# 1. BUILD-CONTAINER: Frontend +FROM node:gallium-alpine + +WORKDIR /root + +COPY ./frontend /root + +RUN yarn && yarn build + +# 2. BUILD-CONTAINER: Server +FROM rust:alpine + +WORKDIR /root + +RUN apk add --no-cache musl-dev + +COPY ./bin /root/bin +COPY ./lib /root/lib +COPY ./server /root/server +COPY ./Cargo.toml /root/Cargo.toml +COPY ./Cargo.lock /root/Cargo.lock + +RUN cargo build --workspace --release + +# 3. RUNTIME-CONTAINER: run server with frontend as assets +FROM alpine:latest + +WORKDIR /root + +COPY --from=0 /root/dist /root/assets +COPY --from=1 /root/target/release/adf-bdd-server /root/server + +ENTRYPOINT ["./server"] +