-
Notifications
You must be signed in to change notification settings - Fork 397
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
Add dockerfile for cross. #878
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC2086 | ||
|
||
set -x | ||
set -eo pipefail | ||
|
||
if [[ -z "${TARGET}" ]]; then | ||
export TARGET="aarch64-unknown-linux-gnu" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should always have this image, so it's a sensible target. |
||
fi | ||
if [[ -z "${CROSS_TARGET_CROSS_IMAGE}" ]]; then | ||
CROSS_TARGET_CROSS_IMAGE="ghcr.io/cross-rs/cross:main" | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This way we use the CI default if present, but have a reasonable target if testing our CI configurations locally. |
||
|
||
main() { | ||
docker run --rm -e TARGET \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
"${CROSS_TARGET_CROSS_IMAGE}" sh -c ' | ||
#!/usr/bin/env sh | ||
td="$(mktemp -d)" | ||
git clone --depth 1 https://github.com/cross-rs/rust-cpp-hello-word "${td}" | ||
cd "${td}" | ||
cross run --target "${TARGET}" | ||
' | ||
} | ||
|
||
main "${@}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
FROM ubuntu:20.04 as rust | ||
ARG DEBIAN_FRONTEND=noninteractive | ||
COPY docker/lib.sh docker/cross.sh / | ||
COPY ./ /project | ||
RUN /cross.sh /project | ||
|
||
# we build our images in 2 steps, to ensure we have a compact | ||
# image, since we want to add our current subdirectory | ||
FROM ubuntu:20.04 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've decided to Ubuntu as a base so it's consistent with all our other images. |
||
COPY --from=rust /root/.cargo /root/.cargo | ||
COPY --from=rust /root/.rustup /root/.rustup | ||
|
||
# need some basic devtools, and requirements for docker | ||
RUN apt-get update && apt-get install --assume-yes --no-install-recommends \ | ||
ca-certificates \ | ||
curl \ | ||
git | ||
|
||
RUN curl -fsSL https://get.docker.com | sh | ||
|
||
ENV CROSS_CONTAINER_IN_CONTAINER=1 \ | ||
PATH=/root/.cargo/bin:$PATH |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env bash | ||
# shellcheck disable=SC1090,SC1091 | ||
|
||
set -x | ||
set -euo pipefail | ||
|
||
. lib.sh | ||
|
||
main() { | ||
local project_dir="${1}" | ||
|
||
install_packages ca-certificates curl gcc libc6-dev | ||
|
||
cd "${project_dir}" | ||
curl --proto "=https" --tlsv1.2 --retry 3 -sSfL https://sh.rustup.rs | sh -s -- -y | ||
source "${HOME}"/.cargo/env | ||
cargo install --path . --locked | ||
|
||
purge_packages | ||
|
||
rm -rf "${0}" | ||
} | ||
|
||
main "${@}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added this so we can test docker-in-docker scenarios where the
CROSS_CONTAINER_IN_CONTAINER
envvar has already been set.