From bdbcf6de13d46183a2b816e1e7899fc7eb1ac560 Mon Sep 17 00:00:00 2001 From: cypherkitty Date: Fri, 13 Sep 2024 12:56:30 -0700 Subject: [PATCH 1/2] Bring devcontainers --- .devcontainer/Dockerfile | 43 +++++++++++++++++++++++++++++++++ .devcontainer/devcontainer.json | 9 +++++++ 2 files changed, 52 insertions(+) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..87dadf70 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,43 @@ +FROM ubuntu:24.04 + +RUN apt update && apt install -y curl wget git build-essential + +#################### Installation #################### +# Install Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +#RUN rustup component add rustfmt + +# Install Node.js and npm +# installs nvm (Node Version Manager) +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash +ENV NVM_DIR="~/.nvm" +ENV NODE_VERSION 22.8.0 + +RUN ls -la /root/.nvm && ls -la /root/.nvm/nvm.sh + +RUN . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default +ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH + +################ Setup ################ +# Install sccache (cargo is too slow) +#RUN cargo install sccache@0.8.1 +ENV RUSTC_WRAPPER=sccache +RUN wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz \ + && tar xzf sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz \ + && mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \ + && chmod +x /usr/local/bin/sccache + +# Install cargo-chef +RUN cargo install cargo-chef --locked + +# Cache dependencies with cargo chef +RUN cargo chef cook --release --recipe-path recipe.json + +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + +RUN cd wasm && wasm-pack build --target web + +RUN cd web-cli/ui npm install diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..7094ef56 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,9 @@ +{ + "build": { + "dockerfile": "Dockerfile" + }, + "features": { + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, + "ghcr.io/earthly/devcontainer-features/earthly:1": {} + } +} \ No newline at end of file From 7aa19a85ebba2ca8c0a76d2cfd9360f3494873c7 Mon Sep 17 00:00:00 2001 From: cypherkitty Date: Fri, 13 Sep 2024 20:01:42 -0700 Subject: [PATCH 2/2] Bring devcontainers --- .devcontainer/Dockerfile | 55 +++++++++++++++++---------------- .devcontainer/devcontainer.json | 12 +++++-- Earthfile | 2 +- core/Cargo.toml | 3 ++ 4 files changed, 42 insertions(+), 30 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 87dadf70..2589d4f5 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,28 +1,22 @@ -FROM ubuntu:24.04 +FROM debian:bookworm -RUN apt update && apt install -y curl wget git build-essential +RUN apt update && apt install -y curl wget git build-essential pkg-config libssl-dev #################### Installation #################### -# Install Rust +#Earthly +ENV EARTHLY_VERSION="v0.8.15" +ENV EARTHLY_RELEASE="https://github.com/earthly/earthly/releases/download/${EARTHLY_VERSION}/earthly-linux-amd64" +RUN wget ${EARTHLY_RELEASE} -O /usr/local/bin/earthly \ + && chmod +x /usr/local/bin/earthly \ + && /usr/local/bin/earthly bootstrap --with-autocomplete + +#Rust +ENV PATH="/root/.cargo/bin:${PATH}" RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y -#RUN rustup component add rustfmt - -# Install Node.js and npm -# installs nvm (Node Version Manager) -RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash -ENV NVM_DIR="~/.nvm" -ENV NODE_VERSION 22.8.0 - -RUN ls -la /root/.nvm && ls -la /root/.nvm/nvm.sh - -RUN . $NVM_DIR/nvm.sh \ - && nvm install $NODE_VERSION \ - && nvm alias default $NODE_VERSION \ - && nvm use default -ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH +RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh +RUN rustup target add x86_64-unknown-linux-gnu -################ Setup ################ -# Install sccache (cargo is too slow) +# Sccache (cargo is too slow) #RUN cargo install sccache@0.8.1 ENV RUSTC_WRAPPER=sccache RUN wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0.8.1-x86_64-unknown-linux-musl.tar.gz \ @@ -30,14 +24,23 @@ RUN wget https://github.com/mozilla/sccache/releases/download/v0.8.1/sccache-v0. && mv sccache-v0.8.1-x86_64-unknown-linux-musl/sccache /usr/local/bin/sccache \ && chmod +x /usr/local/bin/sccache +# Node.js and npm (with nvm) +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash +ENV NVM_DIR="/root/.nvm" +ENV NODE_VERSION="22.8.0" +RUN . $NVM_DIR/nvm.sh \ + && nvm install $NODE_VERSION \ + && nvm alias default $NODE_VERSION \ + && nvm use default + # Install cargo-chef RUN cargo install cargo-chef --locked +################ Setup ################ +#ENV META_PROJECT_DIR=/meta-secret +#WORKDIR ${META_PROJECT_DIR} # Cache dependencies with cargo chef -RUN cargo chef cook --release --recipe-path recipe.json - -RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - -RUN cd wasm && wasm-pack build --target web +#COPY recipe.json ${META_PROJECT_DIR} +#RUN cargo chef cook --release --target x86_64-unknown-linux-gnu --recipe-path recipe.json -RUN cd web-cli/ui npm install +#RUN cd wasm && wasm-pack build --target web diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7094ef56..9c848e38 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,9 +1,15 @@ { + "name": "MetaSecret", + "build": { - "dockerfile": "Dockerfile" + "dockerfile": "Dockerfile", + "context": ".." }, + + workspaceFolder: "/meta-secret", + workspaceMount: "source=${localWorkspaceFolder},target=/meta-secret,type=bind,consistency=cached", + "features": { - "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}, - "ghcr.io/earthly/devcontainer-features/earthly:1": {} + "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} } } \ No newline at end of file diff --git a/Earthfile b/Earthfile index 6094f16a..cfd2fe9c 100644 --- a/Earthfile +++ b/Earthfile @@ -8,7 +8,7 @@ generate-cargo-chef-recipe: SAVE ARTIFACT recipe.json AS LOCAL recipe.json base-build: - FROM rust:1.80.1 + FROM rust:1.81.0-bookworm RUN rustup component add rustfmt diff --git a/core/Cargo.toml b/core/Cargo.toml index 8b83c97d..4fdf19c8 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -16,6 +16,9 @@ test_utils = [] crate-type = ["cdylib", "lib", "staticlib"] name = "meta_secret_core" +[build] +target = "x86_64-unknown-linux-gnu" + [dependencies] thiserror.workspace = true anyhow.workspace = true