Skip to content

Commit

Permalink
Build web-ui with earthly (#57)
Browse files Browse the repository at this point in the history
Build web-ui with earthly
  • Loading branch information
cypherkitty authored Sep 5, 2024
1 parent 2c6fcdd commit 1e69075
Show file tree
Hide file tree
Showing 15 changed files with 150 additions and 226 deletions.
9 changes: 9 additions & 0 deletions .earthlyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.idea

.DS_Store

web-cli/ui/node_modules
ui/dist

wasm/pkg
42 changes: 0 additions & 42 deletions .github/workflows/core.deploy.yml

This file was deleted.

31 changes: 0 additions & 31 deletions .github/workflows/core.test.yml

This file was deleted.

31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "Testing"

on:
workflow_dispatch:
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest

env:
FORCE_COLOR: 1

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

steps:
- uses: earthly/actions-setup@v1
with:
version: v0.8.0

- uses: actions/checkout@v4

- name: run tests
run: |
earthly --ci +app-test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

target
core/target
schema/target
/schema/openapitools.json
/Cargo.lock
/schema/node_modules/
Expand Down
68 changes: 68 additions & 0 deletions Earthfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
VERSION 0.8
FROM scratch

generate-cargo-chef-recipe:
FROM lukemathwalker/cargo-chef:latest-rust-1.80-bookworm
COPY . .
RUN cargo chef prepare --recipe-path recipe.json
SAVE ARTIFACT recipe.json AS LOCAL recipe.json

base-build:
FROM rust:1.80.1

# Install sccache (cargo is too slow)
#RUN cargo install [email protected]
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

#RUN cargo install wasm-pack slooooow
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
RUN rustup component add rustfmt

# Cache dependencies with cargo chef
COPY recipe.json .
RUN cargo chef cook --release --recipe-path recipe.json
RUN cd wasm && wasm-pack build

wasm-build:
BUILD +base-build
FROM +base-build
COPY . .

WORKDIR /wasm
RUN wasm-pack build --target web
SAVE ARTIFACT pkg

web-build:
FROM node:22.7-bookworm

ENV PROJECT_UI_DIR=web-cli/ui

# Cache npm dependencies
WORKDIR ${PROJECT_UI_DIR}
COPY ${PROJECT_UI_DIR}/package.json .
RUN npm install && npm install --dev

COPY +wasm-build/pkg ./pkg

WORKDIR /
COPY . .

RUN ls -la .

WORKDIR ${PROJECT_UI_DIR}
RUN npm run build
SAVE IMAGE meta-secret-web:latest

app-test:
BUILD +base-build
FROM +base-build
COPY . .

RUN cargo test --release
21 changes: 0 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,4 @@

clean:
rm -rf schema/target

build_wasm:
cd wasm && wasm-pack build --target web

#rm -rf ui/pkg
#cp -R wasm/pkg ui

build_js: build_wasm
cd ui && npm install vue-tsc
cd ui && npm run build

generate_typescript_models:
cd ../meta-secret-core/schema && make generate_schema_type_script
cp -r ../meta-secret-core/schema/target/core-models-ts/model ui/src

install_wasm_pack:
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
cargo install cargo-generate

wasm_test:
cd wasm && wasm-pack test --firefox

Expand Down
1 change: 1 addition & 0 deletions recipe.json

Large diffs are not rendered by default.

38 changes: 0 additions & 38 deletions schema/Makefile

This file was deleted.

22 changes: 0 additions & 22 deletions schema/schema.yaml

This file was deleted.

28 changes: 0 additions & 28 deletions web-cli/Makefile

This file was deleted.

Loading

0 comments on commit 1e69075

Please sign in to comment.