From 03a3539e5c194293edc2868aa61baab62168133e Mon Sep 17 00:00:00 2001 From: Ruben Nijveld Date: Tue, 9 Apr 2024 20:10:56 +0200 Subject: [PATCH] Initial commit --- .github/dependabot.yml | 7 ++ .github/workflows/build-push.yml | 17 +++ .github/workflows/check.yml | 12 +++ .github/workflows/docker.yml | 40 +++++++ Dockerfile | 178 +++++++++++++++++++++++++++++++ LICENSE | 25 +++++ README.md | 1 + 7 files changed, 280 insertions(+) create mode 100644 .github/dependabot.yml create mode 100644 .github/workflows/build-push.yml create mode 100644 .github/workflows/check.yml create mode 100644 .github/workflows/docker.yml create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..3eb9d4e --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,7 @@ +version: 2 +updates: +- package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/build-push.yml b/.github/workflows/build-push.yml new file mode 100644 index 0000000..f7dc7d3 --- /dev/null +++ b/.github/workflows/build-push.yml @@ -0,0 +1,17 @@ +name: Build and push + +permissions: + contents: read + packages: write + +on: + push: + branches: + - main + schedule: + - cron: '15 2 * * SUN' + +jobs: + build-and-push: + uses: ./.github/workflows/docker.yml + secrets: inherit diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..ac51988 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,12 @@ +name: Checks + +permissions: + contents: read + +on: + pull_request: + +jobs: + build: + uses: ./.github/workflows/docker.yml + secrets: inherit diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..5deada2 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,40 @@ +name: Docker + +on: + workflow_call: + +jobs: + build: + strategy: + matrix: + include: + - version: stable + latest: false + - version: beta + latest: false + - version: nightly + latest: false + - version: 1.77 + latest: true + - version: 1.76 + latest: false + uses: "tweedegolf/actions-container-helpers/.github/workflows/container-image.yml@main" + with: + push: ${{ github.ref == 'refs/heads/main' }} + build-args: | + RUSTUP_VERSION=1.27.0 + RUSTUP_SHA256_AMD64=a3d541a5484c8fa2f1c21478a6f6c505a778d473c21d60a18a4df5185d320ef8 + RUSTUP_SHA256_ARM64=76cd420cb8a82e540025c5f97bda3c65ceb0b0661d5843e6ef177479813b0367 + CARGO_BINSTALL_VERSION=1.6.4 + CARGO_BINSTALL_SHA256_AMD64=c44726d931b0748bb8159d21be1fa1514c9fd60cd5f00defd6d8e7c1e835deac + CARGO_BINSTALL_SHA256_ARM64=0e5aa3daa7b76412c0ddacb575aeabdfd14ae6aeb8470399cac6cfbd77455514 + SCCACHE_VERSION=0.7.7 + SCCACHE_SHA256_AMD64=ed0010b4dcaccce42b9dc8699257134a113d0ca16dfb7db890356135218322c9 + SCCACHE_SHA256_ARM64=e7ecabac9a703e53a8b06e84b0058fcf242239d164050537bc399387160320fb + CARGO_UDEPS_VERSION=0.1.47 + CARGO_UDEPS_SHA256_AMD64=d98267271652f87c3516bf8623ebd86a3afcada304714e47cacdb0a96bb6df0c + CARGO_UDEPS_SHA256_ARM64=445c6ef1325d247a1e31481d34ecdd5a7ae87f702aff40cfa9dd8ce2ea8f2783 + RUST_VERSION=${{matrix.version}} + tags: | + ghcr.io/tweedegolf/rust-dev:${{matrix.version}} + ${{ matrix.latest && 'ghcr.io/tweedegolf/rust-dev:latest' || '' }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..37fba8d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,178 @@ +FROM docker.tgrep.nl/docker/debian:bookworm + +RUN set -eux; \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + build-essential \ + unzip \ + xz-utils \ + zlib1g-dev \ + libclang1 \ + clang \ + gdb \ + lldb \ + lld \ + llvm \ + cmake \ + valgrind \ + pkg-config \ + libssl-dev \ + libpq-dev \ + libsqlite3-dev \ + binaryen \ + crossbuild-essential-amd64 \ + crossbuild-essential-arm64 \ + ; \ + rm -rf /var/lib/apt/lists/*; + +ARG RUSTUP_VERSION +ENV RUSTUP_VERSION ${RUSTUP_VERSION} + +ARG RUSTUP_SHA256_AMD64 +ARG RUSTUP_SHA256_ARM64 + +ARG RUST_VERSION +ENV RUST_VERSION ${RUST_VERSION:-stable} + +ARG RUST_COMPONENTS="rustfmt clippy rust-analysis rls rust-src" + +ENV RUSTUP_HOME=/usr/local/rustup \ + CARGO_HOME=/usr/local/cargo \ + PATH=/usr/local/cargo/bin:$PATH + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) rustArch="x86_64-unknown-linux-gnu"; rustupSha256=${RUSTUP_SHA256_AMD64} ;; \ + arm64) rustArch="aarch64-unknown-linux-gnu"; rustupSha256=${RUSTUP_SHA256_ARM64} ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + wget -O /usr/local/bin/rustup-init "https://static.rust-lang.org/rustup/archive/${RUSTUP_VERSION}/${rustArch}/rustup-init"; \ + if [ ! -z "${rustupSha256}" ]; then \ + echo "${rustupSha256} */usr/local/bin/rustup-init" | sha256sum -c -; \ + else \ + echo "Checksum for rustup-init not verified"; \ + fi; \ + chmod +x /usr/local/bin/rustup-init; \ + rustup-init -y --no-modify-path --default-toolchain "${RUST_VERSION}"; \ + rustup target add wasm32-unknown-unknown; \ + rustup target add aarch64-unknown-linux-gnu; \ + rustup target add x86_64-unknown-linux-gnu; \ + chmod -R a+rw ${RUSTUP_HOME} ${CARGO_HOME}; \ + rm /usr/local/bin/rustup-init; \ + rustup --version; \ + cargo --version; \ + rustc --version; + +ARG SCCACHE_VERSION +ENV SCCACHE_VERSION ${SCCACHE_VERSION} + +ARG SCCACHE_SHA256_AMD64 +ARG SCCACHE_SHA256_ARM64 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) sccacheArch="x86_64-unknown-linux-musl"; sccacheSha256=${SCCACHE_SHA256_AMD64} ;; \ + arm64) sccacheArch="aarch64-unknown-linux-musl"; sccacheSha256=${SCCACHE_SHA256_ARM64} ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + wget -O "/tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}.tar.gz" \ + "https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-${sccacheArch}.tar.gz"; \ + if [ ! -z "${sccacheSha256}" ]; then \ + echo "${sccacheSha256} */tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}.tar.gz" | sha256sum -c -; \ + else \ + echo "Checksum for sccache not verified"; \ + fi; \ + cd /tmp; \ + tar xvf "/tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}.tar.gz"; \ + mv "/tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}/sccache" /usr/local/bin/sccache; \ + chmod a+x /usr/local/bin/sccache; \ + rm -rf "/tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}/"; \ + rm -rf "/tmp/sccache-v${SCCACHE_VERSION}-${sccacheArch}.tar.gz"; \ + sccache --version; + +ARG CARGO_BINSTALL_VERSION +ENV CARGO_BINSTALL_VERSION ${CARGO_BINSTALL_VERSION} + +ARG CARGO_BINSTALL_SHA256_AMD64 +ARG CARGO_BINSTALL_SHA256_ARM64 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) cargo_binstall_arch="x86_64-unknown-linux-musl"; cargo_binstall_sha256=${CARGO_BINSTALL_SHA256_AMD64} ;; \ + arm64) cargo_binstall_arch="aarch64-unknown-linux-musl"; cargo_binstall_sha256=${CARGO_BINSTALL_SHA256_ARM64} ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + wget -O "/tmp/cargo-binstall-$cargo_binstall_arch.tgz" \ + "https://github.com/cargo-bins/cargo-binstall/releases/download/v${CARGO_BINSTALL_VERSION}/cargo-binstall-$cargo_binstall_arch.tgz"; \ + if [ ! -z "${cargo_binstall_sha256}" ]; then \ + echo "${cargo_binstall_sha256} */tmp/cargo-binstall-${cargo_binstall_arch}.tgz" | sha256sum -c -; \ + else \ + echo "Checksum for cargo-binstall not verified"; \ + fi; \ + cd /tmp; \ + tar xvf "/tmp/cargo-binstall-$cargo_binstall_arch.tgz"; \ + mv /tmp/cargo-binstall /usr/local/bin/cargo-binstall; \ + chmod a+x /usr/local/bin/cargo-binstall; \ + rm -rf "/tmp/cargo-binstall-$cargo_binstall_arch.tgz"; \ + cargo binstall -V; + +RUN set -eux; \ + cargo binstall --no-confirm \ + cargo-audit \ + cargo-outdated \ + cargo-bloat \ + cargo-llvm-lines \ + cargo-watch \ + cargo-edit \ + cargo-chef \ + cargo-sweep \ + cargo-deny \ + trunk \ + mdbook \ + wasm-bindgen-cli \ + sqlx-cli; \ + sqlx --version; \ + wasm-bindgen --version; \ + mdbook --version; \ + trunk --version; \ + cargo deny --version; \ + cargo sweep --version; \ + cargo chef --version; \ + cargo upgrade --version; \ + cargo llvm-lines --version; \ + cargo bloat --version; \ + cargo outdated --version; \ + cargo audit --version; + +ARG CARGO_UDEPS_VERSION +ENV CARGO_UDEPS_VERSION ${CARGO_UDEPS_VERSION} + +ARG CARGO_UDEPS_SHA256_AMD64 +ARG CARGO_UDEPS_SHA256_ARM64 + +RUN set -eux; \ + dpkgArch="$(dpkg --print-architecture)"; \ + case "${dpkgArch##*-}" in \ + amd64) udepsArch="x86_64-unknown-linux-musl"; udepsSha256=${CARGO_UDEPS_SHA256_AMD64} ;; \ + arm64) udepsArch="aarch64-unknown-linux-musl"; udepsSha256=${CARGO_UDEPS_SHA256_ARM64} ;; \ + *) echo >&2 "unsupported architecture: ${dpkgArch}"; exit 1 ;; \ + esac; \ + wget -O "/tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}.tar.gz" \ + "https://github.com/est31/cargo-udeps/releases/download/v${CARGO_UDEPS_VERSION}/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}.tar.gz"; \ + if [ ! -z "${udepsSha256}" ]; then \ + echo "${udepsSha256} */tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}.tar.gz" | sha256sum -c -; \ + else \ + echo "Checksum for cargo-udeps not verified"; \ + fi; \ + cd /tmp; \ + tar xvf "/tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}.tar.gz"; \ + mv "/tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}/cargo-udeps" /usr/local/cargo/bin/cargo-udeps; \ + chmod a+x /usr/local/cargo/bin/cargo-udeps; \ + rm -rf "/tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}/"; \ + rm -rf "/tmp/cargo-udeps-v${CARGO_UDEPS_VERSION}-${udepsArch}.tar.gz"; \ + cargo udeps --version; + +# RUN cargo install diesel_cli --no-default-features --features "postgres sqlite" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..28e9412 --- /dev/null +++ b/LICENSE @@ -0,0 +1,25 @@ +Copyright (c) 2024 Tweede Golf and Contributors + +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..c6aae30 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Rust development Docker images