8000 Fix our dockerfile (once again) by Davidson-Souza · Pull Request #245 · vinteumorg/Floresta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix our dockerfile (once again) #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/target
# ignores perf data and generated performance graphs
perf.*
*.svg
config.toml
/builds
data/
output.log
tmp/
.pre-commit-config.yaml
10 changes: 10 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,13 @@ jobs:

- run: cargo build --verbose
- run: cargo test --verbose

build-docker:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: build the docker image
run: docker build -t dlsz/floresta:latest .

16 changes: 15 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
FROM rust:1.74.0@sha256:fd45a543ed41160eae2ce9e749e5b3c972625b0778104e8962e9bfb113535301 as builder
FROM debian:11.6-slim@sha256:171530d298096f0697da36b3324182e872db77c66452b85783ea893680cc1b62 AS builder

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
curl \
git \
libssl-dev \
pkg-config

RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/root/.cargo/bin:${PATH}"
RUN rustup default 1.74.0

WORKDIR /opt/app

COPY Cargo.* ./
COPY florestad/ florestad/
COPY crates/ crates/
COPY fuzz/ fuzz/
RUN --mount=type=cache,target=/usr/local/cargo/registry \
cargo build --release

Expand All @@ -14,5 +27,6 @@ COPY --from=builder /opt/app/target/release/florestad /usr/local/bin/florestad
RUN chmod +x /usr/local/bin/florestad

EXPOSE 50001
EXPOSE 8332

CMD [ "florestad" ]
3 changes: 3 additions & 0 deletions florestad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,6 @@ json-rpc = [
"jsonrpc-core-client",
]
default = ["experimental-p2p", "json-rpc", "compact-filters"]

[build-dependencies]
toml = "0.5.10"
43 changes: 25 additions & 18 deletions florestad/build.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
fn main() {
let git_description = std::process::Command::new("git")
.args(["describe", "--tags", "--always", "--dirty"])
.output()
.map(|output| {
assert!(
output.status.success(),
"Failed to run git describe. Is git installed?"
);
let mut git_description = String::from_utf8(output.stdout).unwrap();
git_description.pop(); // remove the trailing newline
git_description
})
.expect("Failed to run git describe. Is git installed?");

let version = get_version_from_git().unwrap_or_else(|| get_version_from_manifest().unwrap());
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
let runtime = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
Expand All @@ -29,12 +16,32 @@ fn main() {
})
.expect("Failed to run rustc --version. Is rustc installed?");

let version =
format!("version {git_description} compiled for {arch}-{os}-{runtime} with {rustc}");
println!("cargo:rustc-env=LONG_VERSION={}", version);
println!("cargo:rustc-env=GIT_DESCRIBE={}", git_description);
let long_version = format!("version {version} compiled for {arch}-{os}-{runtime} with {rustc}");
println!("cargo:rustc-env=LONG_VERSION={}", long_version);
println!("cargo:rustc-env=GIT_DESCRIBE={}", version);

// re-run if either the build script or the git HEAD changes
println!("cargo:rerun-if-changed=../.git/HEAD");
println!("cargo:rerun-if-changed=build.rs");
}

fn get_version_from_manifest() -> Result<String, std::io::Error> {
let manifest = std::fs::read_to_string("Cargo.toml")?;
let toml: toml::Value = toml::from_str(&manifest).unwrap();
Ok(toml["package"]["version"].as_str().unwrap().to_string())
}

fn get_version_from_git() -> Option<String> {
std::process::Command::new("git")
.args(["describe", "--tags", "--always", "--dirty"])
.output()
.map(|output| {
if !output.status.success() {
return None;
}
let mut git_description = String::from_utf8(output.stdout).unwrap();
git_description.pop(); // remove the trailing newline
Some(git_description)
})
.ok()?
}
Loading
0