Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
optimaze docker image size
appflowy6fa7b0632a84
diff --git a/backend/Dockerfile b/backend/Dockerfileindex fbf1b732c4..38c62d794d 100644--- a/backend/Dockerfile+++ b/backend/Dockerfile@@ -1,11 +1,23 @@-FROM rust:1.56.1+FROM rust:1.56.1 as builderWORKDIR /app-COPY . .-ENV SQLX_OFFLINE true+COPY . .WORKDIR /app/backend+ENV SQLX_OFFLINE trueRUN RUSTFLAGS="-C opt-level=2" cargo build --release --bin backend-RUN cp target/release/backend backend+# Size optimization+#RUN strip ./target/release/backend++FROM debian:bullseye-slim AS runtime+WORKDIR /app+RUN apt-get update -y \+ && apt-get install -y --no-install-recommends openssl \+ # Clean up+ && apt-get autoremove -y \+ && apt-get clean -y \+ && rm -rf /var/lib/apt/lists/*++COPY --from=builder /app/backend/target/release/backend /usr/local/bin/backend+COPY --from=builder /app/backend/configuration configurationENV APP_ENVIRONMENT production-EXPOSE 8000-ENTRYPOINT ["./backend"]\ No newline at end of file+CMD ["backend"]diff --git a/backend/Makefile b/backend/Makefileindex ca0e154ea1..cb97934842 100644--- a/backend/Makefile+++ b/backend/Makefile@@ -1,4 +1,5 @@ROOT = "./scripts"+SEMVER_VERSION=$(shell grep version Cargo.toml | awk -F"\"" '{print $$2}' | head -n 1).PHONY: init_database run_docker run_testdiff --git a/backend/src/service/doc/edit/edit_actor.rs b/backend/src/service/doc/edit/edit_actor.rsindex bca1bf3696..19d31ce18c 100644--- a/backend/src/service/doc/edit/edit_actor.rs+++ b/backend/src/service/doc/edit/edit_actor.rs@@ -110,6 +110,7 @@ impl EditDocActor {rev_id,ret,} => {+ log::debug!("Receive new doc user: {:?}, rev_id: {}", user, rev_id);let user = EditUser {user: user.clone(),socket: socket.clone(),diff --git a/backend/tests/document/edit.rs b/backend/tests/document/edit.rsindex 7483f4ee0c..692b49ae10 100644--- a/backend/tests/document/edit.rs+++ b/backend/tests/document/edit.rs@@ -174,7 +174,7 @@ async fn delta_sync_while_local_rev_less_than_server_rev() {// │ │ └──────────────────────────────────┘// ◀─────────────────┤ start ws connection// │ │-// ◀─────────────────┤ notify with rev: 3+// ◀─────────────────┤ call notify_open_doc with rev: 3// │ │// ├────Pull Rev─────▶// │ │ ┌──────────────────────────────────┐@@ -197,7 +197,7 @@ async fn delta_sync_while_local_rev_greater_than_server_rev() {DocScript::ClientInsertText(6, "efg"),DocScript::ClientConnectWs,DocScript::AssertClient(r#"[{"insert":"123abcefg\n"}]"#),- // DocScript::AssertServer(r#"[{"insert":"123abcefg\n"}]"#, 3),+ DocScript::AssertServer(r#"[{"insert":"123abcefg\n"}]"#, 3),]).await;}diff --git a/backend/tests/document/helper.rs b/backend/tests/document/helper.rsindex f25f572061..e625f7c9a6 100644--- a/backend/tests/document/helper.rs+++ b/backend/tests/document/helper.rs@@ -27,6 +27,7 @@ pub enum DocScript {AssertClient(&'static str),AssertServer(&'static str, i64),ServerSaveDocument(String, i64), // delta_json, rev_id+ Sleep(u64),}impl DocumentTest {@@ -125,14 +126,17 @@ async fn run_scripts(context: Arc<RwLock<ScriptContext>>, scripts: Vec<DocScriptlet pg_pool = context.read().server_pg_pool.clone();let doc_manager = context.read().server_doc_manager.clone();let edit_doc = doc_manager.get(&doc_id, pg_pool).await.unwrap().unwrap();- assert_eq!(edit_doc.rev_id().await.unwrap(), rev_id);let json = edit_doc.document_json().await.unwrap();assert_eq(s, &json);+ assert_eq!(edit_doc.rev_id().await.unwrap(), rev_id);},DocScript::ServerSaveDocument(json, rev_id) => {let pg_pool = context.read().server_pg_pool.clone();save_doc(&doc_id, json, rev_id, pg_pool).await;},+ DocScript::Sleep(sec) => {+ sleep(Duration::from_secs(sec)).await;+ },}};fut_scripts.push(fut);diff --git a/frontend/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs b/frontend/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rsindex e1f0a47a7b..ae36102640 100644--- a/frontend/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs+++ b/frontend/rust-lib/flowy-document/src/services/doc/edit/edit_doc.rs@@ -185,15 +185,20 @@ impl ClientEditDoc {#[tracing::instrument(level = "debug", skip(self))]fn notify_open_doc(&self) {let rev_id: RevId = self.rev_manager.rev_id().into();-if let Ok(user_id) = self.user.user_id() {let action = OpenDocAction::new(&user_id, &self.doc_id, &rev_id, &self.ws);let strategy = ExponentialBackoff::from_millis(50).take(3);let retry = Retry::spawn(strategy, action);tokio::spawn(async move {match retry.await {- Ok(_) => {},- Err(e) => log::error!("Notify open doc failed: {}", e),+ Ok(_) => {+ //+ log::debug!("Notify open doc success");+ },+ Err(e) => {+ //+ log::error!("Notify open doc failed: {}", e);+ },}});}