Skip to content

Commit

Permalink
Merge pull request #42 from cargo-prebuilt/scripts
Browse files Browse the repository at this point in the history
Reduce size by using base images
  • Loading branch information
harmless-tech authored Jan 3, 2025
2 parents c371515 + 2e96c83 commit 251b4b8
Show file tree
Hide file tree
Showing 61 changed files with 2,317 additions and 1,583 deletions.
714 changes: 650 additions & 64 deletions .github/workflows/ink-cross.yml

Large diffs are not rendered by default.

85 changes: 69 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,22 @@ Built for x86_64 (amd64) and aarch64 (arm64) platforms.
- From GitHub `docker pull ghcr.io/cargo-prebuilt/ink-cross:$DIST-$TARGET`
- From Quay `docker pull quay.io/cargo-prebuilt/ink-cross:$DIST-$TARGET`

### Dev Images

> [!WARNING]
> Dev images are only hosted on GitHub and are built in pull requests.
> They are not rebuilt weekly and are not meant for general use.
`docker pull ghcr.io/cargo-prebuilt/ink-cross-dev:$DIST-$TARGET`

## Using

Debug Build:

```shell
docker run --rm \
--userns host --user $(id -u):$(id -g) \
-v $HOME/.cargo/registry:/usr/local/cargo/registry \
--userns host --user "$(id -u):$(id -g)" \
-v "$HOME/.cargo/registry:/usr/local/cargo/registry" \
-v ./:/project \
ghcr.io/cargo-prebuilt/ink-cross:stable-$TARGET
```
Expand All @@ -27,21 +35,36 @@ Release Build:

```shell
docker run --rm \
--userns host --user $(id -u):$(id -g) \
-v $HOME/.cargo/registry:/usr/local/cargo/registry \
--userns host --user "$(id -u):$(id -g)" \
-v "$HOME/.cargo/registry:/usr/local/cargo/registry" \
-v ./:/project \
ghcr.io/cargo-prebuilt/ink-cross:stable-$TARGET \
auditable build --verbose --release --locked
```

*`--userns host --user "$(id -u):$(id -g)"` may or may not be needed.*

## Dists

There are 4 dists:
- Pinned: $VERSION-$TARGET (Only the latest rust version gets an updated image weekly)
- Pinned: $VERSION-$TARGET

*(ENTRYPOINT runs `cargo +$VERSION $@`)*

(Only the latest rust version gets an updated image weekly)

- Stable: stable-$TARGET

*(ENTRYPOINT runs `cargo +stable $@`)*

- Beta: beta-$TARGET

*(ENTRYPOINT runs `cargo +beta $@`)*

- Nightly: nightly-$TARGET

*(ENTRYPOINT runs `cargo +nightly $@`)*

## Targets

Only rust targets that have host tools can be built.
Expand All @@ -53,7 +76,44 @@ Info:
- nightly-only - Only builds and ships a nightly rust image.
(Also is probably a [tier 3 rust target](https://doc.rust-lang.org/nightly/rustc/platform-support.html))

Targets:
### Clang Targets

Use Clang as their cross compiler and linker.
Libs are under `/usr/$CROSS_TOOLCHAIN/usr/{include,lib}`.

- aarch64-unknown-freebsd (bleeding, nightly-only)
- aarch64-unknown-linux-musl
- armv7-unknown-linux-musleabihf
- x86_64-unknown-freebsd
- x86_64-unknown-linux-musl
- x86_64-unknown-netbsd
- x86_64-unknown-openbsd (bleeding, nightly-only)

### GNU Targets

Use GCC as their cross compiler and linker.
Libs are under `/usr/$CROSS_TOOLCHAIN/{include,lib}`.

- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- powerpc64-unknown-linux-gnu (bleeding, amd64)
- powerpc64le-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
- s390x-unknown-linux-gnu
- sparc64-unknown-linux-gnu (bleeding, amd64)
- x86_64-unknown-linux-gnu

### Native

The native target is special. It contains everything except for the cross-compiling parts.

It also is not the same rust target/toolchain across platforms unlike other images.

- linux/amd64 - x86_64-unknown-linux-gnu
- linux/arm64 - aarch64-unknown-linux-gnu

### All Targets

- aarch64-unknown-freebsd (bleeding, nightly-only)
- aarch64-unknown-linux-gnu
- aarch64-unknown-linux-musl
Expand All @@ -67,20 +127,13 @@ Targets:
- x86_64-unknown-freebsd
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-unknown-netbsd (bleeding)
- x86_64-unknown-netbsd
- x86_64-unknown-openbsd (bleeding, nightly-only)

## Differences between images

- GNU images use gcc.
All other images use clang.
- GNU images are /usr/$CROSS_TOOLCHAIN/{include,lib}.
All others are /usr/$CROSS_TOOLCHAIN/usr/{include,lib}.

## Auditing

All scripts + the dockerfile are included under `/ink` in the image.
All scripts + the dockerfile are included under `/ink` directory in the image.

## Acknowledgments

- [cross-rs](https://github.com/cross-rs/cross)
- Uses some scripts from [cross-rs](https://github.com/cross-rs/cross)
24 changes: 16 additions & 8 deletions build-args.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
#!/bin/bash

echo "CMAKE_VERSION=3.31.2" >> $GITHUB_ENV
echo "OPENSSL_VERSION=openssl-3.4.0" >> $GITHUB_ENV
echo "LLVM_VERSION=19" >> $GITHUB_ENV
echo "MUSL_VERSION=1.2.5" >> $GITHUB_ENV
echo "FREEBSD_MAJOR=13" >> $GITHUB_ENV
echo "NETBSD_MAJOR=10" >> $GITHUB_ENV
# Bypass openbsd cdn listing a release that is not out. (#36)
echo "OPENBSD_MAJOR=7.6" >> $GITHUB_ENV
set -euxo pipefail

{
echo "CMAKE_VERSION=3.31.2"
#echo "OPENSSL_VERSION=openssl-3.4.0"
echo "LLVM_VERSION=19"
echo "MUSL_VERSION=1.2.5"
echo "FREEBSD_MAJOR=13"
echo "NETBSD_MAJOR=10"
# Bypass openbsd cdn listing a release that is not out. (#36)
echo "OPENBSD_MAJOR=7.6"
# Dynamics
echo "BUILD_DATE=$BUILD_DATE"
echo "RUST_VERSION=$LATEST_RUST_VERSION"
echo "OPENSSL_VERSION=$LATEST_OPENSSL_VERSION"
} >> "$GITHUB_ENV"
96 changes: 96 additions & 0 deletions ci/scripts/util_free_space.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env bash
#
# Pulled from https://github.com/apache/arrow/blob/76fa19e61af25d124ec0af5e543110a4672088db/ci/scripts/util_free_space.sh
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.

set -eux

df -h
echo "::group::/usr/local/*"
du -hsc /usr/local/*
echo "::endgroup::"
# ~1GB
sudo rm -rf \
/usr/local/aws-sam-cil \
/usr/local/julia* || :
echo "::group::/usr/local/bin/*"
du -hsc /usr/local/bin/*
echo "::endgroup::"
# ~1GB (From 1.2GB to 214MB)
sudo rm -rf \
/usr/local/bin/aliyun \
/usr/local/bin/azcopy \
/usr/local/bin/bicep \
/usr/local/bin/cmake-gui \
/usr/local/bin/cpack \
/usr/local/bin/helm \
/usr/local/bin/hub \
/usr/local/bin/kubectl \
/usr/local/bin/minikube \
/usr/local/bin/node \
/usr/local/bin/packer \
/usr/local/bin/pulumi* \
/usr/local/bin/sam \
/usr/local/bin/stack \
/usr/local/bin/terraform || :
# 142M
sudo rm -rf /usr/local/bin/oc || : \
echo "::group::/usr/local/share/*"
du -hsc /usr/local/share/*
echo "::endgroup::"
# 506MB
sudo rm -rf /usr/local/share/chromium || :
# 1.3GB
sudo rm -rf /usr/local/share/powershell || :
echo "::group::/usr/local/lib/*"
du -hsc /usr/local/lib/*
echo "::endgroup::"
# 15GB
sudo rm -rf /usr/local/lib/android || :
# 341MB
sudo rm -rf /usr/local/lib/heroku || :
# 1.2GB
sudo rm -rf /usr/local/lib/node_modules || :
echo "::group::/opt/*"
du -hsc /opt/*
echo "::endgroup::"
# 679MB
sudo rm -rf /opt/az || :
echo "::group::/opt/microsoft/*"
du -hsc /opt/microsoft/*
echo "::endgroup::"
# 197MB
sudo rm -rf /opt/microsoft/powershell || :
echo "::group::/opt/hostedtoolcache/*"
du -hsc /opt/hostedtoolcache/*
echo "::endgroup::"
# 5.3GB
sudo rm -rf /opt/hostedtoolcache/CodeQL || :
# 1.4GB
sudo rm -rf /opt/hostedtoolcache/go || :
# 489MB
sudo rm -rf /opt/hostedtoolcache/PyPy || :
# 376MB
sudo rm -rf /opt/hostedtoolcache/node || :
# Remove Web browser packages
sudo apt purge -y \
firefox \
google-chrome-stable \
microsoft-edge-stable
df -h
96 changes: 0 additions & 96 deletions docker/aarch64-unknown-freebsd.Dockerfile

This file was deleted.

Loading

0 comments on commit 251b4b8

Please sign in to comment.