From 83c3340dc347010dce62884ad68e782a26c4cbe7 Mon Sep 17 00:00:00 2001 From: Miguel Garcia Garcia Date: Fri, 23 Feb 2024 14:28:57 +0100 Subject: [PATCH] devops: fix harbor build action Signed-off-by: Miguel Garcia Garcia --- .github/workflows/harbour-build-ui.yml | 9 +-- docker/harbour/ui/Dockerfile | 108 ++++++++----------------- 2 files changed, 38 insertions(+), 79 deletions(-) diff --git a/.github/workflows/harbour-build-ui.yml b/.github/workflows/harbour-build-ui.yml index 635b25fe24..9be320ec19 100644 --- a/.github/workflows/harbour-build-ui.yml +++ b/.github/workflows/harbour-build-ui.yml @@ -2,14 +2,13 @@ name: Build and export CAP UI image on: push: - branches: ['master', 'dev', 'qa', 'test'] - paths: - - "ui/**" - - ".github/workflows/ui-test.yml" + branches: ["master", "dev", "qa", "test", "with-formule"] + # paths: + # - "ui/**" + # - ".github/workflows/ui-test.yml" jobs: build-image: - needs: UITest name: Build and export ui image runs-on: ubuntu-20.04 diff --git a/docker/harbour/ui/Dockerfile b/docker/harbour/ui/Dockerfile index 42c4f6e886..0e664daf44 100644 --- a/docker/harbour/ui/Dockerfile +++ b/docker/harbour/ui/Dockerfile @@ -1,48 +1,6 @@ -FROM nginx:1.24 - - -RUN apt-get update -RUN apt-get install -y curl bash - - -RUN curl -sL https://deb.nodesource.com/setup_14.x | bash - -RUN apt-get install -y nodejs - -RUN apt-get update && apt-get -y install git python g++ make -RUN npm install --global yarn +FROM node:18 as build ENV WORKING_DIR=/tmp/cap -ENV NGINX_HTML_DIR=/usr/share/nginx/html -ENV NODE_OPTIONS="--max-old-space-size=8192" - -RUN mkdir -p $NGINX_HTML_DIR - -# We invalidate cache always because there is no easy way for now to detect -# if something in the whole git repo changed. For docker git clone -# is always the same so it caches it. -ARG CACHE_DATE=$(date) - -# get the code at a specific commit -RUN git clone https://github.com/cernanalysispreservation/analysispreservation.cern.ch.git $WORKING_DIR/ - -WORKDIR $WORKING_DIR/ - -ARG BRANCH_NAME - -RUN echo $BRANCH_NAME - -RUN git fetch --all - -RUN if [ ! -z $BRANCH_NAME ]; then \ - # run commands to checkout a branch - echo "Checkout branch $BRANCH_NAME" && \ - git checkout $BRANCH_NAME && \ - git pull origin $BRANCH_NAME; \ - fi - -RUN git log -10 --pretty=oneline --decorate - -RUN cp -rfp $WORKING_DIR/docker/nginx/nginx.conf /etc/nginx/nginx.conf WORKDIR $WORKING_DIR/ui @@ -61,8 +19,7 @@ ARG PIWIK_SITEID_PROD ARG PIWIK_SITEID_QA ARG PIWIK_SITEID_TEST -RUN echo "" >> $WORKING_DIR/ui/cap-react/.env -RUN echo "" >> $WORKING_DIR/ui/cap-react/.env +RUN mkdir $WORKING_DIR/ui/cap-react RUN echo "PIWIK_URL=$CAP_PIWIK_URL" >> $WORKING_DIR/ui/cap-react/.env RUN echo "ENABLE_E2E=$ENABLE_E2E" >> $WORKING_DIR/ui/cap-react/.env @@ -88,47 +45,50 @@ RUN echo "==========================" RUN echo $CAP_PIWIK_SITEID_TEST RUN echo $PIWIK_SITEID_TEST RUN echo "==========================" -RUN less $WORKING_DIR/ui/cap-react/.env +RUN cat $WORKING_DIR/ui/cap-react/.env RUN echo "==========================" -RUN yarn config set cache ~/.my-yarn-cache-dir - -RUN pwd +COPY ./ui ${WORKING_DIR}/ui RUN yarn install -# RUN yarn upgrade - RUN yarn workspace cap-react build -RUN pwd -RUN ls ./cap-react/dist/* -RUN cp -rfp ./cap-react/dist/* $NGINX_HTML_DIR -# build docs general -WORKDIR $WORKING_DIR/docs +# # build docs general +# WORKDIR $WORKING_DIR/docs -RUN yarn -RUN yarn build +# RUN yarn install +# RUN yarn build -RUN mkdir -p $NGINX_HTML_DIR/docs/general -RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general +# RUN mkdir -p $NGINX_HTML_DIR/docs/general +# RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general -# build docs API -RUN git clone https://github.com/cernanalysispreservation/cap-api-docs.git $WORKING_DIR/cap-api-docs/ -WORKDIR $WORKING_DIR/cap-api-docs +# # build docs API +# RUN git clone https://github.com/cernanalysispreservation/cap-api-docs.git $WORKING_DIR/cap-api-docs/ +# WORKDIR $WORKING_DIR/cap-api-docs -RUN npm install -RUN npm run build +# RUN npm install --maxsockets 1 +# RUN npm run build -RUN mkdir -p $NGINX_HTML_DIR/docs/api -RUN cp -rfp ./web_deploy/* $NGINX_HTML_DIR/docs/api +# RUN mkdir -p $NGINX_HTML_DIR/docs/api +# RUN cp -rfp ./web_deploy/* $NGINX_HTML_DIR/docs/api -# build docs client -RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/ -WORKDIR $WORKING_DIR/cap-client/docs +# # build docs client +# RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/ +# WORKDIR $WORKING_DIR/cap-client/docs -RUN yarn -RUN yarn build +# RUN yarn +# RUN yarn build + +# RUN mkdir -p $NGINX_HTML_DIR/docs/client +# RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/client + +FROM nginx:1.24 + +ENV WORKING_DIR=/tmp/cap +ENV NGINX_HTML_DIR=/usr/share/nginx/html +RUN mkdir -p $NGINX_HTML_DIR -RUN mkdir -p $NGINX_HTML_DIR/docs/client -RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/client +COPY ./docker ${WORKING_DIR}/docker +COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf +COPY --from=build ${WORKING_DIR}/ui/cap-react/dist/* $NGINX_HTML_DIR