Skip to content
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

Fix: revision in CI Docker image #1119

Merged
merged 7 commits into from
Dec 16, 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
11 changes: 7 additions & 4 deletions .github/actions/dockerfiles/Dockerfile.signer.debian
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
FROM rust:1.81.0-slim-bookworm AS build

ARG GIT_COMMIT
RUN test -n "$GIT_COMMIT" || (echo "GIT_COMMIT not set" && false)

ARG CARGO_BUILD_ARGS="--release"

# Install dependencies.
Expand All @@ -14,10 +17,10 @@ RUN apt-get install -y --no-install-recommends \
npm \
default-jre \
g++ && \
apt-get clean && rm -rf /var/lib/apt/lists/*
apt-get clean && rm -rf /var/lib/apt/lists/*

RUN npm install -g pnpm@9
RUN npm install -g @openapitools/openapi-generator-cli
RUN npm install -g pnpm@9 && \
npm install -g @openapitools/openapi-generator-cli

WORKDIR /code/sbtc
COPY . .
Expand All @@ -32,5 +35,5 @@ COPY --from=build /code/sbtc/target/debug/signer /usr/local/bin/signer
# gettext provides envsubst

RUN apt-get update && apt-get install -y ca-certificates gettext --no-install-recommends && \
apt-get clean && rm -rf /var/lib/apt/lists/*
apt-get clean && rm -rf /var/lib/apt/lists/*
CMD ["/usr/local/bin/signer --config /signer-config.toml --migrate-db"]
2 changes: 2 additions & 0 deletions .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ jobs:
labels: ${{ steps.docker_metadata.outputs.labels }}
target: ${{ matrix.docker_target }}
push: true
build-args: |
GIT_COMMIT=${{ github.ref_name }}
15 changes: 11 additions & 4 deletions signer/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::env;

fn main() {
set_up_build_info();
// compile_protos();
Expand All @@ -11,11 +13,16 @@ pub fn set_up_build_info() {

let version = String::from_utf8_lossy(&output.stdout);

let git_hash = std::process::Command::new("git")
let git_output = std::process::Command::new("git")
.args(["rev-parse", "HEAD"])
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).to_string())
.unwrap_or_default();
.output();

let git_hash = match git_output {
Ok(output) if output.status.success() && !output.stdout.is_empty() => {
String::from_utf8_lossy(&output.stdout).to_string()
}
_ => std::env::var("GIT_COMMIT").unwrap_or_default(),
};

let env_abi = std::env::var("CARGO_CFG_TARGET_ENV").unwrap();
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
Expand Down
Loading