plandex-ai / plandex

AI driven development in your terminal. Designed for large, real-world tasks.
https://plandex.ai
GNU Affero General Public License v3.0
10.65k stars 740 forks source link

Fixes a major mounting issue in the docker-compose.yml #140

Closed appreciated closed 3 months ago

appreciated commented 4 months ago

This is a really nasty issue and easy to overlook. It causes the data in the docker container not to be persisted externally.

Important - If the docker compose file was used before:

Back up the data the following way:

docker compose cp plandex-server:/root/plandex-server plandex-server-backup

Check if the folder plandex-server-backup contains a folder orgs

Start with the new configuration:

docker compose up -d

Apply the backup:

docker compose cp plandex-server-backup/. plandex-server:/root/plandex-server

Related Issues

This is caused by the same issue mentioned in #9

danenania commented 3 months ago

I'm a bit confused by this. In production, the Plandex server looks for the file system at /plandex-server by default:

From server/db/fs.go:

var BaseDir string

func init() {
    home, err := os.UserHomeDir()
    if err != nil {
        panic(fmt.Errorf("error getting user home dir: %v", err))
    }

    BaseDir = os.Getenv("PLANDEX_BASE_DIR")
    if BaseDir == "" {
        if os.Getenv("GOENV") == "development" {
            BaseDir = filepath.Join(home, "plandex-server")
        } else {
            BaseDir = "/plandex-server"
        }
    }
}

In production on Plandex Cloud, the file system is mounted at /plandex-server and it works. So why is /root/plandex-server needed with docker-compose? Does it still end up as /plandex-server from the server's perspective or does it also require that PLANDEX_BASE_DIR is set to /root/plandex-server?

I can test this but I want to be sure I understand the issue before merging. Ty!!

appreciated commented 3 months ago

@danenania This was my own fault, thanks for clearing it up for me. I started the server in development mode. This happened since development is the default value in _env and I didn't bother to change it. I think this could be avoided in future simply by changing the default to "production" in the _env.

One question, why do you bother passing GOENV into the docker container? Wouldn't it be better to remove it completely from the _env and setting it constant to "production" in the Dockerfile? Using /root/ as the home directory inside the docker container does not seem useful to me.