ref: improving development environment and instructions (#5180)

* improving development environment and instructions

* minor edits as requested

* fix typo in  DEVELOPMENT.md

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Phil Miesle 2024-12-12 12:01:05 +00:00 committed by GitHub
commit d1821cb466
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 391 additions and 157 deletions

View file

@ -1,29 +1,35 @@
# Source: https://github.com/a5chin/python-uv
FROM debian:bookworm-slim AS builder
FROM ghcr.io/astral-sh/uv:python3.12-bookworm-slim
ENV CARGO_HOME="/opt/.cargo"
# Set timezone
ENV TZ=UTC
SHELL [ "/bin/bash", "-o", "pipefail", "-c" ]
# Set up work directory
WORKDIR /workspace
WORKDIR /opt
# Install additional dev dependencies
RUN apt-get update && apt-get install -y \
zsh \
curl \
git \
build-essential \
npm \
lsof \
procps \
vim \
less \
net-tools \
sudo \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
# The installer requires curl (and certificates) to download the release archive
# hadolint ignore=DL3008
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates curl
# Create the vscode user and group with the expected UID and GID (1000)
RUN groupadd -g 1000 langflow && \
useradd -m -u 1000 -g 1000 -s /bin/zsh langflow && \
echo "langflow ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
# Run uv installer
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
# Set default shell to Zsh
SHELL ["/bin/zsh", "-c"]
RUN echo 'export PS1="%~ %# "' >> /home/langflow/.zshrc
FROM mcr.microsoft.com/vscode/devcontainers/base:bookworm
ENV CARGO_HOME="/opt/.cargo"
ENV PATH="$CARGO_HOME/bin/:$PATH"
ENV PYTHONUNBUFFERED=True
ENV UV_LINK_MODE=copy
WORKDIR /opt
COPY --from=builder --chown=vscode: $CARGO_HOME $CARGO_HOME
# Set the default user
USER langflow

60
.devcontainer/README.md Normal file
View file

@ -0,0 +1,60 @@
# Langflow Demo Codespace Readme
These instructions will walk you through the process of running a Langflow demo via GitHub Codespaces.
If you want a faster and easier demo experience with Langflow, DataStax Langflow is a hosted environment with zero setup: [Sign up for a free account.](https://astra.datastax.com/signup?type=langflow)
## Create a Codespace in GitHub
To setup the demo in Codespace:
1. Navigate to the Langflow repo
2. On the "Code <>" button, select the "Codespaces" tab
3. Click the green "Create codespace on..." button (or "+" icon if you want more options) to create a new Codespace
## Wait for everything to install
After the codespace is opened, there will be two phases to the process. It will take ≈5-10 minutes to complete.
* **Phase 1**: Building Container; you can click on the "Building Codespace" link to watch the logs
* **Phase 2**: Building Langflow; the terminal will now show `Running postCreateCommand...`, similar to:
```
✔ Finishing up...
⠸ Running postCreateCommand...
sudo chown -R langflow .venv .mypy_cache src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend && make install_frontend && mak…
```
Once completed, this terminal window will close.
You now need to manually build the frontend. Open a new Terminal and run command:
```bash
make build_frontend
```
This will take a short period of time, you should have a message similar to `Building frontend static files` and the command will complete successfully.
Installation is now complete.
## Start up the Service
Open a new Terminal, and type `uv run langflow run`.
The service will start, and you will may notice a dialog in the lower right indicating there is a port available to connect to. However, the service will not be ready until you see the welcome banner:
```
╭───────────────────────────────────────────────────────────────────╮
│ Welcome to ⛓ Langflow │
│ │
│ │
│ Collaborate, and contribute at our GitHub Repo 🌟 │
│ │
│ We collect anonymous usage data to improve Langflow. │
│ You can opt-out by setting DO_NOT_TRACK=true in your environment. │
│ │
│ Access http://127.0.0.1:7860 │
╰───────────────────────────────────────────────────────────────────╯
```
At this point you can connect to the service via the port, or if the dialog is gone you can find the "Forwarded Address" on the "Ports" tab (which is next the "Terminal" tab). If there is no port forwarded, you can click the "Forward a Port" button on the "Ports" tab, and forward `7860`.

View file

@ -1,15 +0,0 @@
# Langflow Demo Codespace Readme
These instructions will walk you through the process of running a Langflow demo via GitHub Codespaces.
## Setup
### Create a Codespace in GitHub
To setup the demo, simply navigate to the Langflow repo, click the "+" button, and select "Create new Codespace". This will automatically create a new codespace in your browser, which you can use for the demo.
### Wait for everything to install
After the codespace is opened, you should see a new Terminal window in VS Code where langflow is installed. Once the install completes, `langflow` will launch the webserver and your application will be available via devcontainer port.
Note: VS Code should prompt you with a button to push once the port is available.

View file

@ -1,33 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
{
"name": "Langflow Demo Container",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:3.10",
"features": {
"ghcr.io/devcontainers/features/aws-cli:1": {},
"ghcr.io/devcontainers/features/docker-in-docker": {},
"ghcr.io/devcontainers/features/node": {}
},
"customizations": {
"vscode": {
"extensions": [
"actboy168.tasks",
"GitHub.copilot",
"ms-python.python",
"eamodio.gitlens",
"GitHub.vscode-pull-request-github"
]
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "pipx install 'langflow>=0.0.33' && langflow --host 0.0.0.0"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View file

@ -1,25 +1,14 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/universal
{
"name": "Langflow Dev Container",
"build": {
"context": "..",
"dockerfile": "Dockerfile"
},
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/node": {},
"ghcr.io/dhoeric/features/hadolint:1": {}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "make install_frontend && make install_backend",
"postStartCommand": "make init",
// Configure tool-specific properties.
"postCreateCommand": "sudo chown -R langflow .venv .mypy_cache src/frontend/node_modules src/frontend/build src/backend/base/langflow/frontend && make install_frontend && make install_backend",
"customizations": {
"vscode": {
"extensions": [
@ -44,8 +33,48 @@
}
}
},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
"remoteUser": "vscode"
"remoteUser": "langflow",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"workspaceFolder": "/workspace",
"forwardPorts": [7860, 3000],
"containerEnv": {
"FRONTEND_START_FLAGS": "--host"
},
"mounts": [
{
"source": "${localWorkspaceFolderBasename}-frontend-node_modules",
"target": "/workspace/src/frontend/node_modules",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-frontend-build",
"target": "/workspace/src/frontend/build",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-backend-frontend",
"target": "/workspace/src/backend/base/langflow/frontend",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-venv",
"target": "/workspace/.venv",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-mypy-cache",
"target": "/workspace/.mypy_cache",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-dist",
"target": "/workspace/dist",
"type": "volume"
},
{
"source": "${localWorkspaceFolderBasename}-backend-dist",
"target": "/workspace/src/backend/base/dist",
"type": "volume"
}
]
}