Gary-Ascuy / rust-rest-api

Automate tool sub-command to create a docker image for Rocket Project and build/publish them using Alpine OS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust Rocket / Cargo Doccker Base Project

Example project to test Rust, it looks like a language that you definitly you need to learn in next years.

I fact that I learn in my path as a developer is that learn new things it is always important/critical/required for us.

References

Goals

  • Rust
  • Rocket
  • Cargo
  • WSL
  • Windows Tools / 2020
  • Windows Terminal
  • WSL/Ubuntu

VS Code

Open a WSL/Ubuntu in new Windows Terminal, Navigate to a folder you'd like to open in VS Code, like /mnt/d/develop, then:

$ code .
Ref

Development Setup

Environment - nightly build it is required for rocket.

$ rustc --version
$ rustc 1.45.0-nightly (a74d1862d 2020-05-14)
$ cargo --version
$ cargo 1.45.0-nightly (cb06cb269 2020-05-08)

To install Nightly Version

$ rustup default nightly
$ rustup override set nightly

Fix for cargo-watch and cargo-edit only Win/WSL-Ubuntu.

sudo apt install gcc libssl-dev pkg-config

Install tool sub-commands

$ cargo install cargo-watch
$ cargo install cargo-edit
$ cargo install cargo-rocket-docker

Development Mode

Run in Watch Mode

$ cargo watch -x run

Alternative when has problems

$ cargo watch -s 'cargo run'

Release Mode

Build Project

$ cargo build --release

Run Project

$ cargo run --release

Production Build Setup

cargo docker --build
cargo docker --push

and Docker images are available into Docker Hub/Gary Ascuy

garyascuy/cargo-rocket-example:1.0.0
OS/ARCH: linux/amd64
SIZE: 4.31 MB
LAST PUSHED: 12 minutes ago by garyascuy

Run Containers

$ docker run -d -p 3666:3666 garyascuy/cargo-rocket-example

and you can use the docker images production in everywhere like K8s.

open http://localhost:3666
open http://localhost:3666/home

Links

Tools

Disclaimer: I really hate M$/Windows stacks since it is really sad for opensource projects, but it looks interesting

About

Created by Gary Ascuy and Follow me in LinkedIn or GitHub if you want :P.

About

Automate tool sub-command to create a docker image for Rocket Project and build/publish them using Alpine OS.

License:MIT License


Languages

Language:Dockerfile 59.5%Language:Rust 40.5%