Merge branch 'main' into feat/dup-doc-in-db-row

This commit is contained in:
Zack Fu Zi Xiang 2024-09-09 12:48:23 +08:00
commit c9479985c2
No known key found for this signature in database
5 changed files with 27 additions and 10 deletions

View File

@ -40,4 +40,10 @@ RUN apt-get update -y \
COPY --from=builder /app/target/release/appflowy_cloud /usr/local/bin/appflowy_cloud
ENV APP_ENVIRONMENT production
ENV RUST_BACKTRACE 1
ARG APPFLOWY_APPLICATION_PORT
ARG PORT
ENV PORT=${APPFLOWY_APPLICATION_PORT:-${PORT:-8000}}
EXPOSE $PORT
CMD ["appflowy_cloud"]

View File

@ -40,4 +40,10 @@ COPY --from=builder /app/target/release/admin_frontend /usr/local/bin/admin_fron
COPY --from=builder /app/admin_frontend/assets /app/assets
ENV RUST_BACKTRACE 1
ENV RUST_LOG info
ARG ADMIN_FRONTEND_PORT
ARG PORT
ENV PORT=${ADMIN_FRONTEND_PORT:-${PORT:-3000}}
EXPOSE $PORT
CMD ["admin_frontend"]

View File

@ -2,21 +2,28 @@ use tracing::warn;
#[derive(Debug, Clone)]
pub struct Config {
pub host: String,
pub port: u16,
pub redis_url: String,
pub gotrue_url: String,
pub appflowy_cloud_url: String,
}
impl Config {
pub fn from_env() -> Self {
Config {
pub fn from_env() -> Result<Config, anyhow::Error> {
let cfg = Config {
host: get_or_default("ADMIN_FRONTEND_HOST", "0.0.0.0"),
port: get_or_default("ADMIN_FRONTEND_PORT", "3000")
.parse()
.map_err(|e| anyhow::anyhow!("failed to parse ADMIN_FRONTEND_PORT as u16, err: {}", e))?,
redis_url: get_or_default("ADMIN_FRONTEND_REDIS_URL", "redis://localhost:6379"),
gotrue_url: get_or_default("ADMIN_FRONTEND_GOTRUE_URL", "http://localhost:9999"),
appflowy_cloud_url: get_or_default(
"ADMIN_FRONTEND_APPFLOWY_CLOUD_URL",
"http://localhost:8000",
),
}
};
Ok(cfg)
}
}

View File

@ -27,7 +27,7 @@ async fn main() {
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.init();
let config = Config::from_env();
let config = Config::from_env().unwrap();
info!("config loaded: {:?}", &config);
let gotrue_client = gotrue::api::Client::new(reqwest::Client::new(), &config.gotrue_url);
@ -65,7 +65,8 @@ async fn main() {
.nest_service("/web-api", web_api_router)
.nest_service("/assets", ServeDir::new("assets"));
let listener = TcpListener::bind("0.0.0.0:3000")
let address = format!("{}:{}", config.host, config.port);
let listener = TcpListener::bind(address)
.await
.expect("failed to bind to port");
info!("listening on: {:?}", listener);

View File

@ -4,16 +4,13 @@ use app_error::AppError;
use collab_folder::Folder;
use shared_entity::dto::workspace_dto::PublishedView;
use super::folder_view::{to_dto_view_icon, to_view_layout, view_is_space};
use super::folder_view::{to_dto_view_icon, to_view_layout};
pub fn collab_folder_to_published_outline(
folder: &Folder,
publish_view_ids: &HashSet<String>,
) -> Result<PublishedView, AppError> {
let mut unviewable = HashSet::new();
for private_section in folder.get_all_private_sections() {
unviewable.insert(private_section.id);
}
for trash_view in folder.get_all_trash_sections() {
unviewable.insert(trash_view.id);
}
@ -117,7 +114,7 @@ fn to_publish_view(
})
.collect();
let is_published = publish_view_ids.contains(view_id);
if view_is_space(&view) || is_published || !pruned_view.is_empty() {
if is_published || !pruned_view.is_empty() {
Some(PublishedView {
view_id: view.id.clone(),
name: view.name.clone(),