From aef145dbc99924d5c24e219a6df78001ac802134 Mon Sep 17 00:00:00 2001 From: Jason Frey Date: Tue, 19 Mar 2024 14:17:24 -0400 Subject: [PATCH] Add a Dockerfile for building the ui-components package --- .dockerignore | 2 ++ .gitignore | 1 + Dockerfile | 13 +++++++++++++ bin/build | 34 ++++++++++++++++++++++++++++++++++ pkg/.gitkeep | 0 5 files changed, 50 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 bin/build create mode 100644 pkg/.gitkeep diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..0cb30658bf --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +/node_modules/ +/pkg/*.tgz diff --git a/.gitignore b/.gitignore index 8716a78ef9..426e0d4997 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ vendor.css coverage yarn.lock package-lock.json +pkg/ diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..7c3f07e44d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM python:2.7-buster + +SHELL ["/bin/bash", "--login", "-c"] + +RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash +RUN nvm install 14 +RUN npm install --global yarn + +WORKDIR /ui-components +COPY . /ui-components +RUN git clean -fdx +RUN yarn install +RUN yarn pack diff --git a/bin/build b/bin/build new file mode 100755 index 0000000000..cbb82d49e0 --- /dev/null +++ b/bin/build @@ -0,0 +1,34 @@ +#!/bin/bash + +set -e + +image="docker.io/manageiq/ui-components:latest" + +# Build the image, which will build the package +docker build . -t $image --no-cache + +# Extract the package from the image +container_id=$(docker create $image) +package=$(docker run --rm -it --entrypoint /bin/bash $image -c "ls -1 manageiq-ui-components-*.tgz" | tr -d '\r') +docker cp "$container_id:/ui-components/$package" pkg +docker rm "$container_id" + +echo +echo "Package 'pkg/$package' has been built." +echo + +# Optionally publish the image +read -r -p "Publish the package now? (y/N) " -n 1 +echo +echo +if [[ "$REPLY" =~ ^[Yy]$ ]]; then + pushd pkg >/dev/null + npm login + npm publish --access public $package + popd >/dev/null +else + echo "You can manually publish the package with:" + echo " cd pkg" + echo " npm login" + echo " npm publish --access public $package" +fi diff --git a/pkg/.gitkeep b/pkg/.gitkeep new file mode 100644 index 0000000000..e69de29bb2