Giter VIP home page Giter VIP logo

back-end-boilerplate's Introduction

Quick start for development:

  • Install the rust toolchain by following these instructions
  • Install VSCode plugin maklad:rustanalyzer
  • Install docker and docker-compose
    • For Debian based Linux distributions (includes Ubuntu):
      • sudo apt install docker.io
      • sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
      • sudo chmod +x /usr/local/bin/docker-compose
      • To run docker and docker-compose without needing sudo: sudo groupadd docker && sudo usermod -aG docker $USER. Then logout and login back in again to your computer.
    • For MacOS:
      • brew install --cask docker
    • For Windows: Install Docker Desktop for Windows

and then run the following commands:

# builds database image and rust development images
# and runs the database and server as containers where requests
# can be made to the server on port 3030
docker-compose up

The server will recompile on any source file changes.

Database migrations

Write timestamped sql files e.g.20221214151701_example.sql and then move them into the cargo_workspace/migrations directory. The server will reload and apply these migrations.

back-end-boilerplate's People

Contributors

charles-johnson avatar

Watchers

 avatar

back-end-boilerplate's Issues

'safe.directory' errors running cargo in docker on WSL host

I'm assuming these errors are somehow WSL related, but I haven't boot up my Ubuntu partition yet so technically this is an unconfirmed assumption.

When running docker-compose up --build server I get the following error. (After fixing #2.)

server_1  | [Running 'cargo run']
server_1  | error: failed to get `env_logger` as a dependency of package `server v0.1.0 (/cargo_workspace/server)`
server_1  |
server_1  | Caused by:
server_1  |   failed to initialize index git repository (in "/cargo_workspace/cargo/registry/index/github.com-1ecc6299db9ec823")
server_1  |
server_1  | Caused by:
server_1  |   config value 'safe.directory' was not found; class=Config (7); code=NotFound (-3)

safe.directory is apparently an option added in git 2.35.2 to address a CVE. It was then apparently expanded to support * as an opt-out in git 2.36.

Cargo however appears to not use the command line version git. (The docker image comes with git 2.30.2.) Instead it uses the git2 crate. I haven't tracked down what this version of git this corresponds to for this version of cargo.

Adding RUN git config --system --replace-all safe.directory '*' to Dockerfile yields a different but related error.

server_1  | [Running 'cargo run']
server_1  | error: failed to get `env_logger` as a dependency of package `server v0.1.0 (/cargo_workspace/server)`
server_1  |
server_1  | Caused by:
server_1  |   failed to initialize index git repository (in "/cargo_workspace/cargo/registry/index/github.com-1ecc6299db9ec823")
server_1  |
server_1  | Caused by:
server_1  |   repository path '/cargo_workspace/cargo/registry/index/github.com-1ecc6299db9ec823/' is not owned by current user; class=Config (7); code=Owner (-36)

cp: cannot create regular file 'cargo_workspace/cargo/bin/cargo-watch': No such file or directory

When running docker-compose up (or docker-compose up --build server) I get the following error.

server_1  |  cp: cannot create regular file 'cargo_workspace/cargo/bin/cargo-watch': No such file or directory

The cause appears to be that the cargo/bin directories under cargo_workspace don't exist. The simple workaround is to create these directories.

The proper fix would probably be to commit these directories to git. This is slightly complicated by the fact that git is file based and doesn't support empty directories. Adding an empty .gitignore file under cargo_workspace/cargo/bin/ and committing that should work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.