Add procedure to deploy langflow on AWS (#1177)
This commit is contained in:
commit
b2d867e9aa
33 changed files with 5645 additions and 27 deletions
|
|
@ -63,7 +63,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
|
|||
# This is the path to the db in the root of the project.
|
||||
# When the user runs the Langflow the database url will
|
||||
# be set dinamically.
|
||||
sqlalchemy.url = sqlite:///../../../langflow.db
|
||||
# sqlalchemy.url = sqlite:///../../../langflow.db
|
||||
|
||||
|
||||
[post_write_hooks]
|
||||
|
|
|
|||
|
|
@ -86,29 +86,31 @@ class Settings(BaseSettings):
|
|||
value = langflow_database_url
|
||||
logger.debug("Using LANGFLOW_DATABASE_URL env variable.")
|
||||
else:
|
||||
logger.debug("No DATABASE_URL env variable, using sqlite database")
|
||||
# logger.debug("No DATABASE_URL env variable, using sqlite database")
|
||||
logger.debug("No DATABASE_URL env variable, using custom database from secrets of {}".format(os.environ["host"]))
|
||||
# Originally, we used sqlite:///./langflow.db
|
||||
# so we need to migrate to the new format
|
||||
# if there is a database in that location
|
||||
if not values["CONFIG_DIR"]:
|
||||
raise ValueError(
|
||||
"CONFIG_DIR not set, please set it or provide a DATABASE_URL"
|
||||
)
|
||||
# if not values["CONFIG_DIR"]:
|
||||
# raise ValueError(
|
||||
# "CONFIG_DIR not set, please set it or provide a DATABASE_URL"
|
||||
# )
|
||||
|
||||
new_path = f"{values['CONFIG_DIR']}/langflow.db"
|
||||
if Path("./langflow.db").exists():
|
||||
if Path(new_path).exists():
|
||||
logger.debug(f"Database already exists at {new_path}, using it")
|
||||
else:
|
||||
try:
|
||||
logger.debug("Copying existing database to new location")
|
||||
copy2("./langflow.db", new_path)
|
||||
logger.debug(f"Copied existing database to {new_path}")
|
||||
except Exception:
|
||||
logger.error("Failed to copy database, using default path")
|
||||
new_path = "./langflow.db"
|
||||
# new_path = f"{values['CONFIG_DIR']}/langflow.db"
|
||||
# if Path("./langflow.db").exists():
|
||||
# if Path(new_path).exists():
|
||||
# logger.debug(f"Database already exists at {new_path}, using it")
|
||||
# else:
|
||||
# try:
|
||||
# logger.debug("Copying existing database to new location")
|
||||
# copy2("./langflow.db", new_path)
|
||||
# logger.debug(f"Copied existing database to {new_path}")
|
||||
# except Exception:
|
||||
# logger.error("Failed to copy database, using default path")
|
||||
# new_path = "./langflow.db"
|
||||
|
||||
value = f"sqlite:///{new_path}"
|
||||
# value = f"sqlite:///{new_path}"
|
||||
value = "mysql+pymysql://{}:{}@{}:3306/{}".format(os.environ["username"],os.environ["password"],os.environ["host"],os.environ["dbname"])
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,10 @@ class Settings(BaseSettings):
|
|||
value = langflow_database_url
|
||||
logger.debug("Using LANGFLOW_DATABASE_URL env variable.")
|
||||
else:
|
||||
logger.debug("No DATABASE_URL env variable, using sqlite database")
|
||||
value = "sqlite:///./langflow.db"
|
||||
# logger.debug("No DATABASE_URL env variable, using sqlite database")
|
||||
logger.debug("No DATABASE_URL env variable, using custom database from secrets of {}".format(os.environ["host"]))
|
||||
# value = "sqlite:///./langflow.db"
|
||||
value = "mysql+pymysql://{}:{}@{}:3306/{}".format(os.environ["username"],os.environ["password"],os.environ["host"],os.environ["dbname"])
|
||||
|
||||
return value
|
||||
|
||||
|
|
|
|||
26
src/frontend/cdk.Dockerfile
Normal file
26
src/frontend/cdk.Dockerfile
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#baseline
|
||||
FROM --platform=linux/amd64 node:19-bullseye-slim AS base
|
||||
RUN mkdir -p /home/node/app
|
||||
RUN chown -R node:node /home/node && chmod -R 770 /home/node
|
||||
RUN apt-get update && apt-get install -y jq curl
|
||||
WORKDIR /home/node/app
|
||||
|
||||
# client build
|
||||
FROM base AS builder-client
|
||||
ARG BACKEND_URL
|
||||
ENV BACKEND_URL $BACKEND_URL
|
||||
RUN echo "BACKEND_URL: $BACKEND_URL"
|
||||
|
||||
WORKDIR /home/node/app
|
||||
COPY --chown=node:node . ./
|
||||
|
||||
COPY ./set_proxy.sh .
|
||||
RUN chmod +x set_proxy.sh && \
|
||||
cat set_proxy.sh | tr -d '\r' > set_proxy_unix.sh && \
|
||||
chmod +x set_proxy_unix.sh && \
|
||||
./set_proxy_unix.sh
|
||||
|
||||
USER node
|
||||
|
||||
RUN npm install --loglevel warn
|
||||
CMD ["npm", "run", "dev:docker"]
|
||||
|
|
@ -197,7 +197,8 @@ export default function FormModal({
|
|||
const isSecureProtocol =
|
||||
window.location.protocol === "https:" || window.location.port === "443";
|
||||
const webSocketProtocol = isSecureProtocol ? "wss" : "ws";
|
||||
const host = isDevelopment ? "localhost:7860" : window.location.host;
|
||||
// const host = isDevelopment ? "localhost:7860" : window.location.host;
|
||||
const host = window.location.host;
|
||||
const chatEndpoint = `/api/v1/chat/${chatId}`;
|
||||
|
||||
return `${
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue