Skip to content

Commit

Permalink
Include license report in container images
Browse files Browse the repository at this point in the history
Extended the Dockerfiles to generate a license report for the 3rd party
dependencies being used and to include the report in the container
image being produced.
  • Loading branch information
sophokles73 authored and eriksven committed Oct 18, 2024
1 parent 0f38d97 commit f5be7d4
Show file tree
Hide file tree
Showing 10 changed files with 204 additions and 15 deletions.
10 changes: 6 additions & 4 deletions components/Dockerfile.fms-consumer
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true
RUN echo "Building for $TARGETARCH"
RUN mkdir components
COPY . components/
WORKDIR /home/rust/src/components
WORKDIR /home/rust/src/components/fms-consumer

RUN cargo build --package fms-consumer --release --target $BUILDTARGET
RUN mv target/${BUILDTARGET}/release/fms-consumer /home/rust
RUN cargo install cargo-about
RUN cargo about generate -o /home/rust/licenses.html ../about.hbs
RUN cargo build --release --target $BUILDTARGET
RUN mv ../target/${BUILDTARGET}/release/fms-consumer /home/rust

FROM scratch

COPY --from=builder /home/rust/fms-consumer /app/fms-consumer
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY LICENSES /app/
COPY --from=builder /home/rust/licenses.html /app/

ENTRYPOINT [ "/app/fms-consumer" ]
10 changes: 6 additions & 4 deletions components/Dockerfile.fms-forwarder
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ ENV CARGO_NET_GIT_FETCH_WITH_CLI=true
RUN echo "Building for $TARGETARCH"
RUN mkdir components
COPY . components/
WORKDIR /home/rust/src/components
WORKDIR /home/rust/src/components/fms-forwarder

RUN cargo build --package fms-forwarder --release --target $BUILDTARGET
RUN mv target/${BUILDTARGET}/release/fms-forwarder /home/rust
RUN cargo install cargo-about
RUN cargo about generate -o /home/rust/licenses.html ../about.hbs
RUN cargo build --release --target $BUILDTARGET
RUN mv ../target/${BUILDTARGET}/release/fms-forwarder /home/rust

FROM scratch

COPY --from=builder /home/rust/fms-forwarder /app/fms-forwarder
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY LICENSES /app/
COPY --from=builder /home/rust/licenses.html /app/

ENTRYPOINT [ "/app/fms-forwarder" ]
10 changes: 6 additions & 4 deletions components/Dockerfile.fms-server
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,17 @@ ENV CARGO_UNSTABLE_SPARSE_REGISTRY=true
RUN echo "Building for $TARGETARCH"
RUN mkdir components
COPY . components/
WORKDIR /home/rust/src/components
WORKDIR /home/rust/src/components/fms-server

RUN cargo build --package fms-server --release --target $BUILDTARGET
RUN mv target/${BUILDTARGET}/release/fms-server /home/rust
RUN cargo install cargo-about
RUN cargo about generate -o /home/rust/licenses.html ../about.hbs
RUN cargo build --release --target $BUILDTARGET
RUN mv ../target/${BUILDTARGET}/release/fms-server /home/rust

FROM scratch

COPY --from=builder /home/rust/fms-server /app/fms-server
COPY LICENSES /app/
COPY --from=builder /home/rust/licenses.html /app/

EXPOSE 8081
ENTRYPOINT [ "/app/fms-server" ]
110 changes: 110 additions & 0 deletions components/about.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!--
SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation
See the NOTICE file(s) distributed with this work for additional
information regarding copyright ownership.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
SPDX-License-Identifier: Apache-2.0
-->
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description"
content="This page contains the license text of 3rd party crates used by this program/component." />
<meta name="author" content="Produced by the Cargo about plugin" />
<meta name="viewport"
content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, width=device-width" />
<title>Third Party Licenses</title>
<style>
@media (prefers-color-scheme: dark) {
body {
background: #333;
color: white;
}
a {
color: skyblue;
}
}
.container {
font-family: sans-serif;
max-width: 800px;
margin: 0 auto;
}
.intro {
text-align: center;
}
.licenses-list {
list-style-type: none;
margin: 0;
padding: 0;
}
.license-used-by {
margin-top: -10px;
}
.license-text {
max-height: 200px;
overflow-y: scroll;
white-space: pre-wrap;
}
</style>
</head>

<body>
<main class="container">
<div class="intro">
<h1>Third Party Licenses</h1>
<p>
This page contains the license text of 3rd party crates used by this program/component.
Any licensing information listed here is based on the declarations made by the individual
Rust crates being used, and is reproduced here without further validation or additional
checking.
</p>
</div>

<h2>Overview of licenses:</h2>
<ul class="licenses-overview">
{{#each overview}}
<li><a href="#{{id}}">{{name}}</a> ({{count}})</li>
{{/each}}
</ul>

<h2>All license text:</h2>
<ul class="licenses-list">
{{#each licenses}}
<li class="license">
<h3 id="{{id}}">{{name}}</h3>
<h4>Used by:</h4>
<ul class="license-used-by">
{{#each used_by}}
<li><a
href="{{#if crate.repository}} {{crate.repository}} {{else}} https://crates.io/crates/{{crate.name}} {{/if}}">{{crate.name}}
{{crate.version}}</a></li>
{{/each}}
</ul>
<pre class="license-text">{{text}}</pre>
</li>
{{/each}}
</ul>
</main>
</body>

</html>
47 changes: 47 additions & 0 deletions components/about.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0

# Config file for cargo about
# For all options see https://embarkstudios.github.io/cargo-about/cli/generate/config.html

# If you add a license in the following section also consider changing deny.toml
accepted = [
"EPL-2.0",
"EPL-1.0",
"Apache-2.0",
"MIT",
"BSD-3-Clause",
"BSD-2-Clause",
"ISC",
"MPL-2.0",
"Zlib",
]

#targets = ["x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl"]
ignore-build-dependencies = true
ignore-dev-dependencies = true
no-clearly-defined = true
workarounds = ["chrono", "prost", "ring", "rustls", "tonic"]
private = { ignore = true }

[unicode-ident]
accepted = ["Unicode-DFS-2016"]

[ring]
accepted = ["OpenSSL"]
1 change: 1 addition & 0 deletions components/fms-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[package]
name = "fms-consumer"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions components/fms-forwarder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[package]
name = "fms-forwarder"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
1 change: 1 addition & 0 deletions components/fms-proto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[package]
name = "fms-proto"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
Expand Down
11 changes: 10 additions & 1 deletion components/fms-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[package]
name = "fms-server"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -32,7 +33,15 @@ readme.workspace = true
async-trait = "0.1"
axum = "0.7"
chrono = { workspace = true, features = ["clock", "serde"] }
clap = { workspace = true, features = ["std", "env", "color", "help", "usage", "error-context", "suggestions"] }
clap = { workspace = true, features = [
"std",
"env",
"color",
"help",
"usage",
"error-context",
"suggestions",
] }
const_format = { version = "0.2" }
env_logger = { workspace = true }
influx-client = { workspace = true }
Expand Down
18 changes: 16 additions & 2 deletions components/influx-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

[package]
name = "influx-client"
publish = false
version.workspace = true
edition.workspace = true
license.workspace = true
Expand All @@ -29,11 +30,24 @@ readme.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { workspace = true, features = ["std", "env", "color", "help", "usage", "error-context", "suggestions"]}
clap = { workspace = true, features = [
"std",
"env",
"color",
"help",
"usage",
"error-context",
"suggestions",
] }
fms-proto = { workspace = true, optional = true }
protobuf = { workspace = true, optional = true }
influxrs = { workspace = true }
isahc = { version = "1.7", default-features = false, features = ["http2", "static-ssl", "static-curl", "text-decoding"] }
isahc = { version = "1.7", default-features = false, features = [
"http2",
"static-ssl",
"static-curl",
"text-decoding",
] }
log = { workspace = true }

[features]
Expand Down

0 comments on commit f5be7d4

Please sign in to comment.