diff --git a/Cargo.lock b/Cargo.lock index 18ea21e..6017357 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1145,7 +1145,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] -name = "rust-service-template" +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "rustful" version = "0.1.0" dependencies = [ "anyhow", @@ -1163,12 +1169,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "rustc-demangle" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" - [[package]] name = "rustix" version = "0.38.25" diff --git a/Cargo.toml b/Cargo.toml index 9d8a434..7a8ac7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rust-service-template" +name = "rustful" version = "0.1.0" edition = "2021" diff --git a/Dockerfile b/Dockerfile index eb18fe7..91e5a38 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,17 @@ # Create a stage for building the application. -ARG RUST_VERSION=1.73.0 -ARG APP_NAME="rust-service-template" -FROM rust:${RUST_VERSION}-slim-bullseye AS build +# version can be latest or specific like 1.73.0 +ARG RUST_VERSION=latest +ARG APP_NAME="rustful" + +FROM rust:${RUST_VERSION} AS builder + ARG APP_NAME + WORKDIR /app +# Install diesel CLI for migration +RUN cargo install diesel_cli --no-default-features --features postgres + # Build the application. # Leverage a cache mount to ~/.cargo/registry # for downloaded dependencies and a cache mount to /app/target/ for @@ -43,6 +50,8 @@ RUN adduser \ appuser USER appuser +RUN apt update && apt install -y openssl libpq-dev pkg-config + # Copy the executable from the "build" stage. COPY --from=build /bin/server /bin/ @@ -50,4 +59,5 @@ COPY --from=build /bin/server /bin/ EXPOSE 5001 # What the container should run when it is started. +# CMD ["bash", "-c", "./author diesel migration run && ./author"] CMD ["/bin/server"] diff --git a/src/common/database.rs b/src/common/database.rs index f39fcec..f4bbdce 100644 --- a/src/common/database.rs +++ b/src/common/database.rs @@ -2,8 +2,6 @@ use diesel::r2d2::{self, ConnectionManager, PooledConnection}; use once_cell::sync::OnceCell; pub type DbCon = diesel::PgConnection; -pub type DieselBackend = diesel::pg::Pg; - pub type Pool = r2d2::Pool>; pub type Connection = PooledConnection>;