-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
6 changed files
with
76 additions
and
22 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,8 @@ | ||
target/ | ||
deploy/ | ||
tests/ | ||
scripts/ | ||
migrations/ | ||
.env | ||
.dockerignore | ||
Dockerfile |
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
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,29 @@ | ||
FROM lukemathwalker/cargo-chef:latest-rust-latest as chef | ||
WORKDIR /app | ||
RUN apt update && apt install lld clang -y | ||
|
||
FROM chef as planner | ||
COPY . . | ||
# Compute a lock-like file for our project | ||
RUN cargo chef prepare --recipe-path recipe.json | ||
|
||
FROM chef as builder | ||
COPY --from=planner /app/recipe.json recipe.json | ||
# Build project dependencies, not our application! | ||
RUN cargo chef cook --release --recipe-path recipe.json | ||
COPY . . | ||
ENV SQLX_OFFLINE true | ||
# Build project | ||
RUN cargo build --release --bin server | ||
|
||
FROM debian:bullseye-slim AS runtime | ||
WORKDIR /app | ||
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/server server | ||
ENV APP_ENVIRONMENT production | ||
ENTRYPOINT ["./server"] |
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 |
---|---|---|
@@ -1,23 +1,18 @@ | ||
use axum::http::StatusCode; | ||
use std::collections::HashMap; | ||
|
||
use crate::helpers::*; | ||
|
||
#[tokio::test] | ||
async fn example_post_ok() { | ||
let app = TestApp::new().await; | ||
let url = app.get_url("/example"); | ||
let mut json = HashMap::new(); | ||
json.insert("ping", "hello"); | ||
let resp = app.reqwest.post(url).json(&json).send().await.unwrap(); | ||
|
||
let resp = app.post("/example", r#"{ "ping": "hello" }"#).await; | ||
assert_eq!(resp.status(), StatusCode::OK); | ||
|
||
let resp = sqlx::query!("SELECT id, uid, ping, created_at FROM example") | ||
.fetch_one(&app.pool) | ||
.fetch_one(&app.db) | ||
.await | ||
.expect("Failed to query db"); | ||
|
||
assert_eq!(resp.id, 1); | ||
assert_eq!(resp.ping, "hello"); | ||
} |
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
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