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(release): fix the Dockerfile #211

Merged
merged 3 commits into from
Jul 31, 2023

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Jul 29, 2023

This commit fixes the broken Dockerfile that is used in release CI. It adds wasmedge installation step in the build, uses xx-cargo instead of cargo, and copies the sed command from Docker's build script that allows xx-cargo to be used with pkg-config in build scripts.

Reference

  1. Docker's build script
  2. xx issue

FYI @cpuguy83 @jprendes

This commit fixes the broken Dockerfile that is used in release CI.
It adds wasmedge installation step in the build, uses `xx-cargo` instead
of cargo, and copies the `sed` command from Docker's build script that
allows xx-cargo to be used with pkg-config in build scripts.

Signed-off-by: jiaxiao zhou <[email protected]>
Dockerfile Outdated
@@ -25,18 +30,25 @@ COPY --link Cargo.toml ./
COPY --link Cargo.lock ./
ARG CRATE=""
ARG TARGETOS TARGETARCH TARGETVARIANT
RUN curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s -- \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to install WasmEdge manually anymore. That's take care automatically during the build process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Dockerfile Outdated
RUN --mount=type=cache,target=/usr/local/cargo/git/db \
--mount=type=cache,target=/usr/local/cargo/registry/cache \
--mount=type=cache,target=/usr/local/cargo/registry/index \
--mount=type=cache,target=/build/src/target,id=runwasi-cargo-build-cache-${TARGETOS}-${TARGETARCH}${TARGETVARIANT} <<EOT
set -e
export "CARGO_NET_GIT_FETCH_WITH_CLI=true"
export RUSTFLAGS='-Clink-arg=-Wl,-rpath,$ORIGIN'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are by default statically linking against wasmedge now. You can remove this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this!
Just a few comments.

cpuguy83
cpuguy83 previously approved these changes Jul 29, 2023
@cpuguy83
Copy link
Member

Looks like just one comment from @jprendes but otherwise LGTM.
Thanks all.

Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thanks again for fixing the Dockerfile!

nit: line 56 replace all the xx-info ... with a single xx-cargo --print-target-triple to compute the output directory:

cp target/$(xx-cargo --print-target-triple)/release/${bin} /build/bin/${bin}

I wished cargo's --out-dir was stable.

Dockerfile Outdated

FROM base AS build
SHELL ["/bin/bash", "-c"]
ARG BUILD_TAGS TARGETPLATFORM
RUN xx-apt-get install -y gcc g++ libc++6-dev zlib1g
RUN xx-apt-get install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev
RUN xx-apt-get install -y libsystemd-dev libdbus-1-dev libseccomp-dev
RUN rustup target add $(xx-info march)-unknown-$(xx-info os)-$(xx-info libc)
Copy link
Collaborator

@jprendes jprendes Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove. xx-cargo runs rustup target add (for target platform) for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -36,7 +41,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/git/db \
if [ -n "${CRATE}" ]; then
package="--package=${CRATE}"
fi
cargo build --release --target=$(xx-info march)-unknown-$(xx-info os)-$(xx-info libc) ${package}
xx-cargo build --release ${package}
Copy link
Collaborator

@jprendes jprendes Jul 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove lines 39 and 40. xx-cargo already sets those variables for you.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done,

@Mossaka
Copy link
Member Author

Mossaka commented Jul 31, 2023

nit: line 56 replace all the xx-info ... with a single xx-cargo --print-target-triple to compute the output directory:

Done.

Thank you @jprendes

@Mossaka Mossaka requested a review from jprendes July 31, 2023 17:49
Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Thanks @Mossaka !

@cpuguy83 cpuguy83 enabled auto-merge July 31, 2023 18:21
@cpuguy83 cpuguy83 disabled auto-merge July 31, 2023 18:21
@cpuguy83 cpuguy83 merged commit d02c2c0 into containerd:main Jul 31, 2023
7 checks passed
@Mossaka Mossaka deleted the release-dockerfile branch July 31, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants