-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6ab49f5
Showing
45 changed files
with
1,668 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.gitignore | ||
**/data | ||
**/docs | ||
.env? | ||
**/migrations | ||
**/scripts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# for sqlx offline to run properly | ||
POSTGRES_USER=myapp | ||
POSTGRES_PASSWORD=password | ||
DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/myapp | ||
|
||
# for configuration.rs | ||
APP_ENVIRONMENT=local | ||
APP_DATABASE__USERNAME=${POSTGRES_USER} | ||
APP_DATABASE__PASSWORD=${POSTGRES_PASSWORD} | ||
APP_SECURITY__SECRET_KEY=secret | ||
|
||
APP_database__username=${POSTGRES_USER} | ||
APP_DATABASE__PASSWORD=${POSTGRES_PASSWORD} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Generated by Cargo | ||
# will have compiled files and executables | ||
debug/ | ||
target/ | ||
|
||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries | ||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html | ||
Cargo.lock | ||
|
||
# These are backup files generated by rustfmt | ||
**/*.rs.bk | ||
|
||
# MSVC Windows builds of rustc generate these, which store debugging information | ||
*.pdb | ||
|
||
# RustRover | ||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can | ||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore | ||
# and can be added to the global gitignore or merged into this file. For a more nuclear | ||
# option (not recommended) you can uncomment the following to ignore the entire idea folder. | ||
#.idea/ | ||
|
||
# Custom | ||
.env | ||
data/ |
58 changes: 58 additions & 0 deletions
58
.sqlx/query-0239c4a304b887f116249a2aa7ffb390c83bbfd13e6174f7153b52bed6a2c553.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
25 changes: 25 additions & 0 deletions
25
.sqlx/query-2d5c7904eb9eb959e7d85e0bc19ed21cf61c8472dcfef4e5cf5a8ed88339c4a0.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
.sqlx/query-5327eaad266e3c258806e25e376ad951c8cd6c1303d9afa4f60537756b520ffe.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
.sqlx/query-87fcf318ae48bb33d6c484c26d251ad991048342ad460bbb78c54898bbfff49a.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
[package] | ||
name = "myapp" | ||
version = "0.1.0" | ||
edition = "2021" | ||
default-run = "myapp" | ||
|
||
[dependencies] | ||
serde = { version = "1.0.204", features = ["derive"] } | ||
serde_json = "1.0.122" | ||
tokio = { version = "1.39.2", features = ["full"] } | ||
axum = { version = "0.7.5", features = [ | ||
"macros", | ||
"form", | ||
"multipart", | ||
"query", | ||
] } | ||
rayon = "1.10.0" | ||
thiserror = "1.0.63" | ||
tracing = { version = "0.1.40", features = ["attributes"] } | ||
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] } | ||
jsonwebtoken = "9.3.0" | ||
once_cell = "1.19.0" | ||
bcrypt = "0.15.1" | ||
chrono = { version = "0.4.38", features = ["clock", "serde"] } | ||
tower-http = { version = "0.5.2", features = [ | ||
"cors", | ||
"trace", | ||
"timeout", | ||
"limit", | ||
] } | ||
axum-extra = { version = "0.9.3", features = ["cookie", "typed-header"] } | ||
sqlx = { version = "0.8.0", features = [ | ||
"runtime-tokio-rustls", | ||
"postgres", | ||
"macros", | ||
"migrate", | ||
"uuid", | ||
"chrono", | ||
"json", | ||
] } | ||
tower = "0.4.13" | ||
uuid = { version = "1.10.0", features = ["serde", "v4"] } | ||
async-trait = "0.1.81" | ||
axum-macros = "0.4.1" | ||
anyhow = "1.0.86" | ||
dotenvy = "0.15.7" | ||
# to generate random number | ||
rand = "0.8.5" | ||
itertools = "0.13.0" | ||
cookie = "0.18.1" | ||
config = "0.14.0" | ||
# to opt-in password instead of opt-out | ||
secrecy = { version = "0.8", features = ["serde"] } | ||
# environment variables are strings for the config crate and it will fail to pick up integers | ||
serde-aux = "4.5.0" | ||
tracing-log = "0.2.0" | ||
num = "0.4.3" | ||
num-format = "0.4.4" | ||
regex = "1.10.6" | ||
rand_pcg = "0.3.1" | ||
tracing-appender = "0.2.3" | ||
log = "0.4.22" | ||
env_logger = "0.11.5" | ||
time = { version = "0.3.36", features = ["macros"] } | ||
serde_with = "3.9.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# syntax=docker/dockerfile:experimental | ||
# The above step enabled specific experimental syntax, namely the | ||
# "--mount-type=cache parameter, a named cache volume managed by | ||
# Docker BuildKit | ||
# https://juliankrieger.dev/blog/combining-docker-buildkit-cargo-chef | ||
|
||
FROM lukemathwalker/cargo-chef:latest as chef | ||
|
||
FROM chef as planner | ||
WORKDIR /app | ||
COPY . . | ||
# Compute a lock-like file for our project | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
|
||
FROM chef as cacher | ||
WORKDIR /app | ||
# Get the recipe file | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build our project dependencies, not our application! | ||
# this is the caching Docker layer! | ||
# Cache dependencies | ||
# I don't know why target=/app/target doesn't work | ||
# but target=/target does | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
--mount=type=cache,target=/target \ | ||
cargo chef cook --release --recipe-path recipe.json | ||
|
||
|
||
FROM chef as builder | ||
WORKDIR /app | ||
# Copy built dependencies over cache | ||
COPY --from=cacher /app/target target | ||
# Copy cargo folder from cache. This includes the package registry and downloaded sources | ||
COPY --from=cacher $CARGO_HOME $CARGO_HOME | ||
COPY . . | ||
# needa run cargo sqlx prepare | ||
ENV SQLX_OFFLINE true | ||
# Build the binary | ||
RUN --mount=type=cache,target=/usr/local/cargo/registry \ | ||
cargo build --release --bin myapp | ||
|
||
|
||
# We do not need the Rust toolchain to run the binary! | ||
FROM debian:bookworm-slim as runtime | ||
WORKDIR /app | ||
# Install OpenSSL - it is dynamically linked by some of our dependencies | ||
# Install ca-certificates - it is needed to verify TLS certificates | ||
# when establishing HTTPS connections | ||
RUN apt-get update -y \ | ||
&& apt-get install -y --no-install-recommends openssl ca-certificates \ | ||
# Clean up | ||
&& apt-get autoremove -y \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY --from=builder /app/target/release/myapp myapp | ||
# Custom config | ||
COPY configuration configuration | ||
ENV APP_ENVIRONMENT development | ||
ENTRYPOINT ["./myapp"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# fullstack-crud |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[application] | ||
# We are using 127.0.0.1 as our host in address, | ||
# we are instructing our application to only accept connec-ions coming from the same machine | ||
host = "127.0.0.1" | ||
port = 3000 | ||
rust_log = "rust_axum=debug,axum=debug,tower_http=debug,bullai=debug" | ||
|
||
[database] | ||
# for development using docker compose, we need to use the service name as host | ||
# for api in docker-compose, host need to be service name, e.g. "postgres" | ||
host = "localhost" | ||
username = "it_should_be_override_by_.env" | ||
password = "it_should_be_override_by_.env" | ||
port = 5432 | ||
require_ssl = false | ||
|
||
[security] | ||
secret_key = "it_should_be_override_by_.env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[application] | ||
host = "0.0.0.0" | ||
port = "80" | ||
|
||
[database] | ||
database_name = "myapp_dev" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[application] | ||
# IPV6 localhost [::] is for macos | ||
host = "[::]" | ||
|
||
[database] | ||
database_name = "myapp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[application] | ||
host = "0.0.0.0" | ||
port = "80" | ||
|
||
[database] | ||
database_name = "myapp_prod" |
Oops, something went wrong.