From 952ac1cd3c33563745119da98ffb43030e6b0506 Mon Sep 17 00:00:00 2001 From: appflowy Date: Sat, 21 Aug 2021 23:19:57 +0800 Subject: [PATCH] config server docker --- .dockerignore | 7 +++++++ backend/.dockerignore | 10 ++++++++++ backend/Cargo.toml | 3 ++- backend/Dockerfile | 15 +++++++++++++++ backend/doc/database_setup.md | 5 ++++- rust-lib/dart-ffi/Cargo.toml | 8 ++++---- rust-lib/flowy-dispatch/src/errors/errors.rs | 8 +------- rust-lib/flowy-dispatch/src/lib.rs | 2 -- 8 files changed, 43 insertions(+), 15 deletions(-) create mode 100644 .dockerignore create mode 100644 backend/.dockerignore create mode 100644 backend/Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..96d83807ed --- /dev/null +++ b/.dockerignore @@ -0,0 +1,7 @@ +.env +.dockerignore +doc/ +scripts/ +rust-lib/target/ +backend/target/ +app_flowy/ \ No newline at end of file diff --git a/backend/.dockerignore b/backend/.dockerignore new file mode 100644 index 0000000000..1719710ae1 --- /dev/null +++ b/backend/.dockerignore @@ -0,0 +1,10 @@ +.env +.dockerignore +spec.yaml +target/ +deploy/ +tests/ +Dockerfile +scripts/ +migrations/ +app_flowy/ \ No newline at end of file diff --git a/backend/Cargo.toml b/backend/Cargo.toml index 987f1184c5..f9e05582dc 100644 --- a/backend/Cargo.toml +++ b/backend/Cargo.toml @@ -42,7 +42,8 @@ features = [ "postgres", "uuid", "chrono", - "migrate" + "migrate", + "offline", ] diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000000..b572ff6108 --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,15 @@ +# We use the latest Rust stable release as base image +FROM rust:1.53.0 +# Let's switch our working directory to `app` (equivalent to `cd app`) +# The `app` folder will be created for us by Docker in case it does not +# exist already. +WORKDIR /app +# Copy all files from our working environment to our Docker image + +COPY . . +# Let's build our binary! +# We'll use the release profile to make it faaaast +WORKDIR /app/backend +RUN cargo build --release +# When `docker run` is executed, launch the binary! +ENTRYPOINT ["./target/release/backend"] diff --git a/backend/doc/database_setup.md b/backend/doc/database_setup.md index 44ac3d83d0..86c25a06c5 100644 --- a/backend/doc/database_setup.md +++ b/backend/doc/database_setup.md @@ -2,6 +2,7 @@ ### Docker + 1. follow the [instructions](https://docs.docker.com/desktop/mac/install/) to install docker. 2. open terminal and run: `docker pull postgres` @@ -25,4 +26,6 @@ export DB_NAME=flowy export DB_PORT=5433 ``` -![img_1.png](img_1.png) \ No newline at end of file +![img_1.png](img_1.png) + +[Docker command](https://docs.docker.com/engine/reference/commandline/builder_prune/) \ No newline at end of file diff --git a/rust-lib/dart-ffi/Cargo.toml b/rust-lib/dart-ffi/Cargo.toml index b29f4558cf..3132ea54aa 100644 --- a/rust-lib/dart-ffi/Cargo.toml +++ b/rust-lib/dart-ffi/Cargo.toml @@ -7,11 +7,11 @@ edition = "2018" [lib] name = "dart_ffi" # this value will change depending on the target os -# for iOS it would be `cdylib` -# for Macos it would be `cdylib` +# for iOS it would be `rlib` +# for Macos it would be `rlib` # for android it would be `c-dylib` -# default cdylib -crate-type = ["cdylib"] +# default rlib +crate-type = ["rlib"] [dependencies] diff --git a/rust-lib/flowy-dispatch/src/errors/errors.rs b/rust-lib/flowy-dispatch/src/errors/errors.rs index 34bd3a6d45..051d5bfd26 100644 --- a/rust-lib/flowy-dispatch/src/errors/errors.rs +++ b/rust-lib/flowy-dispatch/src/errors/errors.rs @@ -7,7 +7,7 @@ use bytes::Bytes; use dyn_clone::DynClone; use protobuf::ProtobufError; use serde::{Serialize, Serializer}; -use std::{fmt, option::NoneError}; +use std::fmt; use tokio::{sync::mpsc::error::SendError, task::JoinError}; pub trait Error: fmt::Debug + DynClone + Send + Sync { @@ -53,12 +53,6 @@ impl From> for DispatchError { } } -impl From for DispatchError { - fn from(s: NoneError) -> Self { - InternalError::UnexpectedNone(format!("Unexpected none: {:?}", s)).into() - } -} - impl From for DispatchError { fn from(s: String) -> Self { InternalError::Other(s).into() } } diff --git a/rust-lib/flowy-dispatch/src/lib.rs b/rust-lib/flowy-dispatch/src/lib.rs index 5e0da9ac9a..779db9a6f2 100644 --- a/rust-lib/flowy-dispatch/src/lib.rs +++ b/rust-lib/flowy-dispatch/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(try_trait)] - mod errors; mod module; mod request;