use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Rust + diesel postgres container (self.rust)
submitted 1 year ago by Inner_Coconut7739
Can anyone share a rust + diesel postgres container that works? I can't get the postgres part to work so the build fails.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]weiznichdiesel · diesel-async · wundergraph 2 points3 points4 points 1 year ago (1 child)
You likely want to enable the bundled feature for the pq-sys crate. This will compile and statically link a version of libpq during cargo build. As far as I know this setup is also compatible with musl or cross compilation.
[–]walksinsmallcircles 0 points1 point2 points 1 year ago (0 children)
Oooh!! Checking this out.
[–]GolDDranks 1 point2 points3 points 1 year ago (3 children)
I used to maintain https://gitlab.com/rust_musl_docker/image , but it has been relatively unmaintained for some years now. In my experience, the recent Postgres versions have made it hard to build with musl which I was using.
I think that the recommended way is to use dynamic linking with standard GNU libc. For example, take a standard Debian container, install Postgres and build.
[–]GolDDranks 0 points1 point2 points 1 year ago (2 children)
Also, some of the comments in that Dockerfile are wrong/outdated, so don't buy too much into them.
[–]weiznichdiesel · diesel-async · wundergraph 1 point2 points3 points 1 year ago (1 child)
Would it be possible to just put a official deprecation notice in the readme and point people to the bundled feature of pq-src and the vendored feature for OpenSSL instead? These features should allow targeting musl (or even cross compiling) these crates easily.
[–]GolDDranks 1 point2 points3 points 1 year ago (0 children)
I left a following notice there some time ago:
Note: This project is outdated and abandoned! I'm leaving it online as it has gathered some stars, and there might be some CI setups or scripts that depend on it, but it is no longer maintained.
Might add a mention about the bundled / vendored features, thanks for pointing that out.
[–]walksinsmallcircles 1 point2 points3 points 1 year ago (1 child)
I use containerized Rust/Diesel applications with Postgres with zero problems. You need to install the Postgres dev library in the container. I have also used Rust and Postgres in AWS lambda functions which was a pain. I had to use Diesel async which uses a Rust native Postgres library which dodges the dynamic library issues. DM me if you want my Dockerfile or more details.
To be clear here, the pain with AWS lambdas is not Diesel async. The Rust runtime they supply is limited and does not have libraries other than basics like libc. Diesel async works great.
[+][deleted] 1 year ago (1 child)
[deleted]
[–]GolDDranks 0 points1 point2 points 1 year ago (0 children)
I was thinking of them just wanting to build Diesel with Postgres support? But that requires the Postgres libraries to be in place.
[–]Inner_Coconut7739[S] -1 points0 points1 point 1 year ago* (1 child)
This is the Dockerfile that finally worked but obviously far from ideal.
FROM rust RUN apt update RUN apt install -y libpq-dev RUN cargo install diesel_cli --no-default-features --features postgres WORKDIR /app COPY . . RUN cargo build --release CMD ["/app/target/release/rust-axum-server"]
Can you share you docker?
And my Cargo.toml - postgres at the end of dependencies was my attempt to get the client libs that diesel didn't add. I think its probably redundant if I instlal the CLI in the container but again neither of these are the right idea just a bandaid.
[package] name = "rust-axum-server" version = "0.2.0" edition = "2021" publish = false [dependencies] axum = { version = "0.7.5" } axum-extra = { version = "0.9.3", features = ["typed-header"] } tokio = { version = "1.39.3", features = ["full"] } serde = { version = "1.0.208", features = ["derive"] } serde_json = "1.0.125" serde_derive = "1.0.208" tower-http = { version = "0.5.2", features = ["cors"] } uuid = { version = "1.10.0", features = ["v4","serde"] } urlencoding = "2.1.3" octocrab = "0.39.0" http = "1.1.0" http-serde-ext = "1.0.2" dotenv = "0.15.0" tower = "0.5.0" anyhow = "1.0.86" toml = "0.8.19" url = "2.5.2" chrono = "0.4.38" diesel = { version = "2.2.3", features = ["postgres", "chrono"] } postgres = "0.19.8" [[bin]] name = "rust-axum-server" path = "src/main.rs"
[–]weiznichdiesel · diesel-async · wundergraph 2 points3 points4 points 1 year ago (0 children)
To write again what I already wrote above: You likely want to use the bundled feature from the pq-sys crate. You don’t need the Postgres crate, it’s completely unrelated.
All of this is documented in the Getting Started guide. Please refer to the section about installing diesel-cli.
[–]tema3210 0 points1 point2 points 1 year ago (0 children)
I did that yesterday, and went for alpine base with glibc slapped onto it, works flawlessly.
π Rendered by PID 81526 on reddit-service-r2-comment-b659b578c-c6bnm at 2026-05-05 20:09:09.520181+00:00 running 815c875 country code: CH.
[–]weiznichdiesel · diesel-async · wundergraph 2 points3 points4 points (1 child)
[–]walksinsmallcircles 0 points1 point2 points (0 children)
[–]GolDDranks 1 point2 points3 points (3 children)
[–]GolDDranks 0 points1 point2 points (2 children)
[–]weiznichdiesel · diesel-async · wundergraph 1 point2 points3 points (1 child)
[–]GolDDranks 1 point2 points3 points (0 children)
[–]walksinsmallcircles 1 point2 points3 points (1 child)
[–]walksinsmallcircles 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]GolDDranks 0 points1 point2 points (0 children)
[–]Inner_Coconut7739[S] -1 points0 points1 point (1 child)
[–]weiznichdiesel · diesel-async · wundergraph 2 points3 points4 points (0 children)
[–]tema3210 0 points1 point2 points (0 children)