diff --git a/.github/workflows/ci-global.yaml b/.github/workflows/ci-global.yaml new file mode 100644 index 00000000..434fd9b3 --- /dev/null +++ b/.github/workflows/ci-global.yaml @@ -0,0 +1,39 @@ +name: CI (global trustify CI) + +on: + push: + branches: + - "main" + pull_request: + branches: + - "main" + workflow_call: + +concurrency: + group: ci-global-${{ github.ref }} + cancel-in-progress: true + +jobs: + build-and-upload-for-global-ci: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: save trustd image + run: | + docker build . -t ghcr.io/trustification/trustd:pr-test -f Dockerfile.server + docker save -o /tmp/trustd.tar ghcr.io/trustification/trustd:pr-test + + - name: Upload trustd image as artifact + uses: actions/upload-artifact@v3 + with: + name: trustd + path: /tmp/trustd.tar + retention-days: 1 + + run-global-ci: + needs: build-and-upload-for-global-ci + uses: trustification/trustify-ci/.github/workflows/global-ci.yml@main + with: + artifact: trustd + server_image: ghcr.io/trustification/trustd:pr-test + run_api_tests: false diff --git a/Dockerfile.server b/Dockerfile.server new file mode 100644 index 00000000..1d53e97a --- /dev/null +++ b/Dockerfile.server @@ -0,0 +1,51 @@ +###################################################################### +# UI +###################################################################### +FROM registry.access.redhat.com/ubi9/nodejs-20:latest AS ui-source +USER 1001 +COPY --chown=1001 . . +RUN npm install -g npm@9 +RUN npm clean-install --ignore-scripts && npm run build && npm run dist + +###################################################################### +# Prepare server +###################################################################### +FROM registry.access.redhat.com/ubi9/ubi:latest AS server-source +ARG server_branch="main" +ARG server_commit + +RUN dnf install git -y +RUN git clone https://github.com/trustification/trustify.git --branch ${server_branch} /trustify/ +RUN cd /trustify/ && if [ -n "${commit}" ]; then git checkout -b commit-branch ${server_commit}; fi +RUN sed -i 's/trustify-ui = { git = "https:\/\/github.com\/trustification\/trustify-ui.git", tag = "static-main" }/trustify-ui = { path = "..\/trustify-ui\/crate" }/g' /trustify/Cargo.toml + +###################################################################### +# Build server +###################################################################### +FROM registry.access.redhat.com/ubi9/ubi:latest AS server-builder + +# Dependencies +RUN dnf install -y openssl-devel gcc + +RUN mkdir /stage/ && \ + dnf install --installroot /stage/ --setop install_weak_deps=false --nodocs -y zlib openssl && \ + dnf clean all --installroot /stage/ + +# Setup Rust +RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y +ENV PATH=${PATH}:/root/.cargo/bin +RUN rustup target add $(uname -m)-unknown-linux-gnu + +# Build source code +COPY --from=ui-source /opt/app-root/src/ /code/trustify-ui/ +COPY --from=server-source /trustify/ /code/trustify/ +RUN cd /code/trustify/ && \ + cargo build --no-default-features --release --target=$(uname -m)-unknown-linux-gnu && \ + find /code/trustify/target/ -name "trustd" -exec cp -av {} /stage/usr/local/bin \; + +###################################################################### +# Builder runner +###################################################################### +FROM registry.access.redhat.com/ubi9/ubi-micro:latest AS server-runner +COPY --from=server-builder /stage/ . +ENTRYPOINT ["/usr/local/bin/trustd"]