[wip] ci: ci work

This commit is contained in:
鲁树人 2024-09-22 19:12:12 +01:00
parent 235612ac91
commit c7983ddce2
4 changed files with 52 additions and 0 deletions

9
.drone.yml Normal file
View File

@ -0,0 +1,9 @@
kind: pipeline
type: docker
name: default
steps:
- name: test
image: 1.81-bookworm
commands:
- cargo test --verbose --all

1
.gitignore vendored
View File

@ -2,4 +2,5 @@ target/
pkg/
pkg-*/
node_modules/
.pnpm-store
*.local

17
Dockerfile Normal file
View File

@ -0,0 +1,17 @@
FROM rust:1.81-bookworm
RUN curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
ARG uid=1998
ARG gid=1998
RUN groupadd -g "$gid" builder \
&& useradd -u "$uid" -g "$gid" -m -d /h builder
USER builder
RUN curl -fsL https://get.pnpm.io/install.sh | ENV="$HOME/.bashrc" SHELL="$(which bash)" bash -
RUN git config --global --add safe.directory /a
ENV PATH="/h/.local/share/pnpm:$PATH"
WORKDIR /a

25
build.sh Normal file
View File

@ -0,0 +1,25 @@
#!/bin/bash -ex
docker volume create umc_rust_cache
docker volume create umc_rust_pnpm_cache
docker volume create umc_rust_target_cache
docker volume create umc_pnpm_loader_cache
docker buildx build --build-arg uid="$(id -u)" --build-arg gid="$(id -g)" -t umc_rust .
umc_rust_id="$(docker run -d -v umc_rust_cache:/h/.cargo -v "${PWD}:/a" -v umc_rust_pnpm_cache:/a/.pnpm-store -v umc_rust_target_cache:/a/target -v umc_pnpm_loader_cache:/a/um_wasm_loader/node_modules --entrypoint /usr/bin/sleep umc_rust infinity)"
docker exec -i -u root "${umc_rust_id}" chown "$(id -u):$(id -g)" \
/h/.cargo \
/a/.pnpm-store \
/a/target \
/a/um_wasm_loader/node_modules
docker exec -i "${umc_rust_id}" bash <<'EOF'
export npm_config_use_node_version=22.9.0
cd um_wasm_loader
pnpm --package-import-method=copy i
pnpm build
pnpm pack
EOF
docker stop "${umc_rust_id}"
docker rm -f "${umc_rust_id}"