mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
optimaze docker image size
This commit is contained in:
parent
2514a65617
commit
6fa7b0632a
@ -1,11 +1,23 @@
|
||||
FROM rust:1.56.1
|
||||
FROM rust:1.56.1 as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
|
||||
ENV SQLX_OFFLINE true
|
||||
COPY . .
|
||||
WORKDIR /app/backend
|
||||
ENV SQLX_OFFLINE true
|
||||
RUN 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 configuration
|
||||
ENV APP_ENVIRONMENT production
|
||||
EXPOSE 8000
|
||||
ENTRYPOINT ["./backend"]
|
||||
CMD ["backend"]
|
||||
|
@ -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_test
|
||||
|
||||
|
@ -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(),
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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<DocScript
|
||||
let 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);
|
||||
|
@ -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);
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user