Skip to content

Commit

Permalink
deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
cn-kali-team committed Feb 11, 2024
1 parent 636c2da commit fcd62a2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/nvd-rs:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build and push helper
uses: docker/build-push-action@v5
with:
Expand All @@ -42,6 +44,8 @@ jobs:
platforms: linux/amd64
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/nvd-helper-rs:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
if: inputs.deploy_to_fly
uses: ./.github/workflows/fly.yml
Expand Down
24 changes: 18 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ WORKDIR /prod
COPY .cargo .cargo
COPY nvd-server/Cargo.toml Cargo.toml
COPY nvd-model/ /nvd-model
RUN cargo fetch
RUN apt-get update
RUN apt-get install -y --no-install-recommends gcc-multilib xz-utils liblz4-tool libc6-dev libssl-dev default-libmysqlclient-dev pkg-config musl-tools patchelf build-essential zlib1g-dev ca-certificates
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo fetch
RUN --mount=type=cache,target=/var/lib/cache/ apt-get update \
apt-get install -y --no-install-recommends gcc-multilib xz-utils liblz4-tool libc6-dev libssl-dev default-libmysqlclient-dev pkg-config musl-tools patchelf build-essential zlib1g-dev ca-certificates
COPY nvd-server/src src
RUN cargo build --release --all-features
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo build --release --all-features

FROM rust:slim-buster AS yew

Expand All @@ -22,12 +28,18 @@ RUN cargo install --locked wasm-bindgen-cli
# 其他模块需要工作区配置
COPY nvd-yew/Cargo.toml Cargo.toml
COPY nvd-model/ /nvd-model
RUN cargo fetch
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo fetch
COPY nvd-yew/index.html index.html
COPY nvd-yew/Trunk.toml Trunk.toml
COPY nvd-yew/static static
COPY nvd-yew/src src
RUN trunk build --release --no-sri
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
trunk build --release --no-sri

# Use any runner as you want
# But beware that some images have old glibc which makes rust unhappy
Expand Down
18 changes: 12 additions & 6 deletions DockerfileHelper
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,27 @@ FROM rust:latest AS helper
WORKDIR /prod
#为了命中docker构建缓存,先拷贝这几个文件进去
COPY .cargo .cargo
RUN apt-get update
RUN apt-get install -y --no-install-recommends gcc-multilib xz-utils liblz4-tool libc6-dev libssl-dev default-libmysqlclient-dev pkg-config musl-tools patchelf build-essential zlib1g-dev ca-certificates
RUN --mount=type=cache,target=/var/lib/cache/ apt-get update \
apt-get install -y --no-install-recommends gcc-multilib xz-utils liblz4-tool libc6-dev libssl-dev default-libmysqlclient-dev pkg-config musl-tools patchelf build-essential zlib1g-dev ca-certificates
COPY .cargo .cargo
COPY helper/Cargo.toml Cargo.toml
COPY nvd-model/ /nvd-model
RUN cargo fetch
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo fetch
COPY helper/src src
RUN cargo build --release
RUN --mount=type=cache,target=/var/cache/buildkit \
CARGO_HOME=/var/cache/buildkit/cargo \
CARGO_TARGET_DIR=/var/cache/buildkit/target \
cargo build --release

# Use any runner as you want
# But beware that some images have old glibc which makes rust unhappy
FROM debian:latest AS runner
WORKDIR /prod
ENV TZ=Asia/Shanghai
RUN apt-get update
RUN apt-get install -y --no-install-recommends libssl-dev default-libmysqlclient-dev ca-certificates
RUN --mount=type=cache,target=/var/lib/cache/ apt-get update \
apt-get install -y --no-install-recommends libssl-dev default-libmysqlclient-dev ca-certificates
COPY --from=helper /prod/target/release/helper /prod
ENTRYPOINT [ "/prod/helper" ]

0 comments on commit fcd62a2

Please sign in to comment.