-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The reproducible build of MigTD binary requires same user and code path, so we provide a `Dockerfile` for reproducibility. Signed-off-by: Jiaqi Gao <[email protected]>
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
FROM ubuntu:22.04 | ||
|
||
# Adding rust binaries to PATH. | ||
ENV PATH="$PATH:/root/.cargo/bin" | ||
WORKDIR /root | ||
|
||
# Install all required packages in one go to optimize the image | ||
# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run | ||
# DEBIAN_FRONTEND is set for tzdata. | ||
RUN apt-get update && \ | ||
DEBIAN_FRONTEND="noninteractive" apt-get install --no-install-recommends -y \ | ||
build-essential unzip ca-certificates curl gcc git libssl-dev pkg-config ssh \ | ||
clang llvm nasm \ | ||
ocaml ocamlbuild wget pkg-config libtool autoconf autotools-dev automake \ | ||
screen expect \ | ||
# cleanup | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* | ||
|
||
# Install rustup and a fixed version of Rust. | ||
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2023-08-28 | ||
RUN rustup component add rust-src | ||
RUN cargo install cargo-xbuild | ||
|
||
RUN git clone --recursive https://github.com/intel/MigTD.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
FOLDER="" | ||
|
||
usage() { | ||
cat << EOM | ||
Usage: $(basename "$0") [OPTION]... | ||
-d <docker file> Path of Dockerfile. | ||
EOM | ||
} | ||
|
||
error() { | ||
echo -e "\e[1;31mERROR: $*\e[0;0m" | ||
exit 1 | ||
} | ||
|
||
process_args() { | ||
while getopts ":f:h" option; do | ||
case "$option" in | ||
f) FOLDER=$OPTARG;; | ||
h) usage | ||
exit 0 | ||
;; | ||
*) | ||
echo "Invalid option '-$OPTARG'" | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z ${FOLDER} ]]; then | ||
error "Please specify the folder of where the Dockerfile is located through -f." | ||
fi | ||
|
||
if [[ ! -f "${FOLDER}/Dockerfile" ]]; then | ||
error "Dockerfile does not exist." | ||
fi | ||
} | ||
|
||
process_args $@ | ||
|
||
pushd ${FOLDER} | ||
|
||
# If the docker image does not exist, build the docker image | ||
set +e && docker image inspect migtd.build.env:latest > /dev/null 2>&1 && set -e | ||
if [ $? != 0 ]; then | ||
docker build -t migtd.build.env \ | ||
--build-arg https_proxy=$https_proxy \ | ||
--build-arg http_proxy=$http_proxy \ | ||
. | ||
fi | ||
|
||
popd | ||
|
||
# Run the docker image | ||
docker run -it --rm migtd.build.env |