This guide provides instructions for setting up and running the LibreChat stack locally, with a focus on a more secure deployment on Apple Silicon. At the moment and in this default configuration, this stack uses Google VertexAI subscription in its configuration due to their generous USD 300 credit.
This project is licensed under the Apache 2.0 License. See the LICENSE files for details.
Before you begin, ensure you have the following installed:
For a secure setup on Apple Silicon, I would recommended to use Colima with Apple’s Virtualization.framework (vz). This allows to separately run different docker stacks on their own VMs, instead of all docker related things into one.
-
Start Colima with
vz: This creates a profile running on Apple's native VM layer.colima start -p aiarm --vm-type=vz --cpu 4 --memory 8 --disk 50 docker context ls docker context use colima-aiarm
(Note: On macOS ≥13, recent Colima versions support the
--vzshorthand.) -
Enable user-namespace remapping: This maps "root in the container" to an unprivileged user in the VM, enhancing security.
colima ssh -p aiarm echo '{ "userns-remap": "default" }' | sudo tee /etc/docker/daemon.json echo 'dockremap:165536:65536' | sudo tee -a /etc/subuid /etc/subgid sudo systemctl restart docker || sudo service docker restart exit
The application stack is configured using an environment file.
-
Create the
.envfile: Copy the template to create your local configuration file.cp template_dot_env .env
-
Configure variables in
.env: Open.envand set the required variables.
With the configuration in place, you can now start the services.
-
Ensure your Docker context is correct:
docker context use colima-aiarm
-
Start the services:
docker compose \ -f docker-compose.yml \ -f compose.hardening.yml \ up -d
-
Check running services: To see the published ports for the services:
docker compose ps --format '{{.Service}} -> {{range .Publishers}}{{.PublishedPort}}{{end}}'
After the stack is running, create the first user, who will have admin privileges.
docker compose -f docker-compose.yml -f compose.hardening.yml exec api npm run create-userIf you need to use the static preview server for artifacts, you can enable it by including its dedicated compose file. This service, along with a Caddy proxy, provides a local HTTPS endpoint for sandpack. I have not yet fully understood how it really works with LibreChat, nethertheless I got it to run.
-
Prerequisites: Ensure you have generated the local SSL certificates using
mkcert.You can install
mkcertandnssvia Homebrew:brew install mkcert nss mkcert -install
-
Local HTTPS with
mkcertandsslip.ioGenerate a self-signed SSL certificate for local development domains.
# Create a directory for secrets if it doesn't exist mkdir -p ./secrets # Generate cert/key files for the local wildcard host mkcert -cert-file ./secrets/sslip.crt -key-file ./secrets/sslip.key \ "preview.127.0.0.1.sslip.io" "*.127.0.0.1.sslip.io"
-
Start the stack with the static preview service: Add the
-f optional/static-preview/compose.ymlflag to yourdocker compose upcommand:docker compose \ --env-file .env \ -f docker-compose.yml \ -f compose.hardening.yml \ -f optional/static-preview/compose.yml \ up -d
-
Verify variables are set in
.env:grep -E '^(PORT|UID|GID|MEILI_MASTER_KEY|RAG_PORT)=' .env -
Preview the resolved Docker Compose configuration: This helps confirm that your
.envvariables are being loaded correctly. You should not see any warnings about missing variables.docker compose --env-file .env config | sed -n '1,60p'
If you still see warnings, it means
.envisn’t being picked up—double-check the path and that you passed--env-file .env.
For backup procedure, see backup/README.md.
The foundation of this Docker Compose stack was adapted from the work of nicedexter. His original setup provided a great starting point for this.
- Fix CORS for artifacts
- Egress squid proxy to prevent successful LLM Prompt hijacking efficiently by whitelisting needed egress domains
- Consider adding https://github.com/martvaha/code-interpreter, https://github.com/Fritsl/LibreChatLocalWebSearchStack and https://github.com/Fritsl/LibreChatConfigurator
- Renovate and CI