GithubHelp home page GithubHelp logo

baitcenter / webapp-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clux/webapp-rs

0.0 1.0 0.0 95 KB

Rust microservice setup with postgres, and diesel + rocket in docker

Dockerfile 1.80% Makefile 24.86% Shell 10.44% TSQL 1.24% PLpgSQL 12.46% Rust 49.21%

webapp-rs's Introduction

Rust microservice setup with rocket and postgres diesel

CircleCI docker pulls docker image info docker tag

A JSON API microservice with database backing all running from a <7MB container.

Developing Easily

Install dependencies, setup rustup env, then start a dev postgres with credentials:

sudo pacman -S postgresql-libs # or distro equivalent
make setup
source env.sh
make db # runs postgres in a container

then run and test in parallel with:

make run
make test

This workflow is the fastest as it does not require waiting for docker builds, nor deal with a local installations of postgres. You just need to install docker, postgresql-libs to manage migrations in a container, and run against it with what's essentially cargo run.

Using docker-compose

You can develop and test production equivalents without rust, without local postgres, without postgres libs, and without diesel-cli locally.

This is the production equivalent flow:

# Build the app with clux/muslrust
make compile
# Put the built binary into a container and compose with a db.
# Then, once the db is up, use clux/diesel-cli to run migrations:
source env.sh
make compose
# Verify
make test

CI

Runs unit tests, musl build, intergration tests with docker compose and pushes to docker hub, all in <2 minutes (using a cache of rust target + registy directories).

Continuous Integration layout and timing

Using Kubernetes

Port to your templated wall of yaml of choice if you know what you are doing.

Caveats

NB: With docker-compose our migration would have to wait for postgres to initialize, either via a sleep or a psql "select 1" attempt. See make compose for more info.

NB: The compile step is required before any build step, so docker-compose up would fail without it. It's possible to fix this by using a multistep docker build for the app, but it makes local build caching harder.

webapp-rs's People

Contributors

clux avatar

Watchers

 avatar

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.