Skip to content

WhatToDo-Organisation/rust_docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

Rust Docker setup for M1 Macs

Running Rust applications with Diesel on M1 Macs can be challenging due to missing necessary libraries. This repository offers a Docker solution to seamlessly run your Rust applications, ensuring compatibility and ease of setup.

Prerequisites:

  • Docker installed on your M1 Mac.

Steps to Run:

  1. Build the Docker Image:

    Navigate to the directory containing the Dockerfile and run:

    docker build -t rust_docker .

    This command builds the Docker image and tags it as rust_docker.

  2. Configuration Changes:

    Before running your application, make sure to adjust the connection URLs in your config.yaml file for the PostgreSQL and QDranT databases. Replace localhost with host.docker.internal. For example:

    database_url: "postgres://dboperator:operatorpass123@host.docker.internal:5432/postgres"
    qdrant_url: "http://host.docker.internal:6333"

    This change allows the Docker container to connect to services running on your host machine.

  3. Run the Docker Container:

    In the root directory of your Rust project, execute:

    docker run -it -p 3000:3000 -v $(pwd):/root/backend_infra rust_docker

    This command:

    • Maps port 3000 of the container to port 3000 on your host machine.
    • Mounts your current directory (your Rust project) to /root/backend_infra in the Docker container. This ensures any changes you make to your local code will reflect in the container instantly.
    • Initiates the container with a Zsh shell, as configured in the Dockerfile.
  4. Inside the Docker Container:

    Once inside the container's shell:

    • Navigate to /root/backend_infra.
    • Run your Rust application as you normally would on a local setup.

Note:

  • This setup uses Zsh for an enhanced shell experience, and the configuration has been copied into the container. Adjustments can be made by modifying the .zshrc file in this repository and rebuilding the Docker image.

  • Always ensure that any services or databases running on your host are properly secured, especially when exposing ports or making connections.

Happy coding! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published