Skip to content

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.

add docker-compose

appflowy8f582faffecc
diff --git a/.github/workflows/backend_general.yml b/.github/workflows/backend_general.yml
index f337545353..5f78a1af57 100644
--- a/.github/workflows/backend_general.yml
+++ b/.github/workflows/backend_general.yml
@@ -3,9 +3,6 @@ name: Backend
on:
push:
branches: [ main ]
- paths:
- - 'backend'
- - 'shared-lib'
pull_request:
branches: [ main ]
@@ -155,5 +152,18 @@ jobs:
- run: cargo clippy -- -D warnings
working-directory: backend/
+ fmt:
+ name: Rustfmt
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - uses: actions-rs/toolchain@v1
+ with:
+ toolchain: nightly
+ override: true
+ - run: rustup component add rustfmt
+ working-directory: backend/
+ - run: cargo fmt --all -- --check
+ working-directory: backend/
diff --git a/backend/Makefile b/backend/Makefile
deleted file mode 100644
index 6828ac6db4..0000000000
--- a/backend/Makefile
+++ /dev/null
@@ -1,3 +0,0 @@
-include scripts/database/database.mk
-
-.PHONY: init_postgres init_database add_migrations run_migrations reset_db echo_db_url
\ No newline at end of file
diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml
new file mode 100644
index 0000000000..6998f1153c
--- /dev/null
+++ b/backend/docker-compose.yml
@@ -0,0 +1,18 @@
+version: '3'
+services:
+ backend:
+ build:
+ context: .
+ dockerfile: Dockerfile
+ depends_on:
+ - db
+ ports:
+ - "8000:8000"
+ db:
+ image: 'postgres:14'
+ environment:
+ POSTGRES_USER: "${POSTGRES_USER}"
+ POSTGRES_DB: "${POSTGRES_DB}"
+ POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}"
+ ports:
+ - '${DB_PORT}:5432'
\ No newline at end of file
diff --git a/backend/scripts/Makefile b/backend/scripts/Makefile
index 1e44f51383..02128967ac 100644
--- a/backend/scripts/Makefile
+++ b/backend/scripts/Makefile
@@ -1,14 +1,11 @@
-#.EXPORT_ALL_VARIABLES:
-#export DB_USER=postgres
-#export DB_PASSWORD=password
-#export DB_NAME=flowy
-#export DB_PORT=5433
-#export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
-#export DB_HOST = "localhost"
+.PHONY: init_database add_migrations run_migrations reset_db
init_database:
${ROOT}/init_database.sh
+run_docker:
+ source $(shell pwd)/env.sh && docker-compose up -d db && docker-compose up -d backend
+
reset_db:
#diesel database reset
sqlx database reset
@@ -22,6 +19,4 @@ run_migrations:
# diesel migration run
sqlx migrate run
-echo_db_url:
- echo ${DATABASE_URL}
diff --git a/backend/scripts/env.sh b/backend/scripts/env.sh
new file mode 100644
index 0000000000..8c9d5db3d3
--- /dev/null
+++ b/backend/scripts/env.sh
@@ -0,0 +1,9 @@
+#!/bin/bash
+
+export DB_USER="${POSTGRES_USER:=postgres}"
+export DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
+export DB_PORT="${POSTGRES_PORT:=5433}"
+export DB_HOST="${POSTGRES_HOST:=localhost}"
+export DB_NAME="${POSTGRES_DB:=flowy}"
+
+export DATABASE_URL=postgres://${DB_USER}:${DB_PASSWORD}@localhost:${DB_PORT}/${DB_NAME}
\ No newline at end of file
diff --git a/backend/scripts/init_database.sh b/backend/scripts/init_database.sh
index d1ed0f10f0..712bdacc10 100755
--- a/backend/scripts/init_database.sh
+++ b/backend/scripts/init_database.sh
@@ -18,11 +18,7 @@ if ! [ -x "$(command -v sqlx)" ]; then
exit 1
fi
-DB_USER="${POSTGRES_USER:=postgres}"
-DB_PASSWORD="${POSTGRES_PASSWORD:=password}"
-DB_PORT="${POSTGRES_PORT:=5433}"
-DB_HOST="${POSTGRES_HOST:=localhost}"
-DB_NAME="${POSTGRES_DB:=flowy}"
+source ./env.sh
if [[ -z "${SKIP_DOCKER}" ]]
then