diff --git a/.github/workflows/image-build.yaml b/.github/workflows/image-build.yaml index 2b0ad637..71a758d5 100644 --- a/.github/workflows/image-build.yaml +++ b/.github/workflows/image-build.yaml @@ -14,6 +14,17 @@ concurrency: cancel-in-progress: true jobs: + server-image-build: + uses: project-openubl/release-tools/.github/workflows/build-push-images.yaml@main + with: + registry: "ghcr.io" + image_name: "${{ github.repository_owner }}/openubl-server" + containerfile: "./Dockerfile.server" + architectures: '[ "amd64", "arm64" ]' + secrets: + registry_username: ${{ github.actor }} + registry_password: ${{ secrets.GITHUB_TOKEN }} + ui-image-build: uses: project-openubl/release-tools/.github/workflows/build-push-images.yaml@main with: diff --git a/Dockerfile.server b/Dockerfile.server new file mode 100644 index 00000000..f3815929 --- /dev/null +++ b/Dockerfile.server @@ -0,0 +1,40 @@ +###################################################################### +# UI +###################################################################### +FROM registry.access.redhat.com/ubi9/nodejs-22:latest AS ui-source +USER 1001 +COPY --chown=1001 . . +RUN cd server/ui/ && \ + npm install -g npm@9 && \ + npm clean-install --ignore-scripts && npm run build && npm run dist && \ + rm -rf node_modules + +###################################################################### +# Build server +###################################################################### +FROM registry.access.redhat.com/ubi9/ubi:latest AS server-builder + +# Dependencies +RUN dnf install -y libxml2-devel 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/openubl/ +RUN cd /code/openubl/ && \ + cargo build --no-default-features --release --target=$(uname -m)-unknown-linux-gnu && \ + find /code/openubl/target/ -name "server" -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/server"] \ No newline at end of file