Skip to content

Commit

Permalink
devops: fix harbor build action
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Garcia Garcia <[email protected]>
  • Loading branch information
miguelgrc committed May 2, 2024
1 parent 1d0a0d7 commit a695479
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 79 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/harbour-build-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
112 changes: 38 additions & 74 deletions docker/harbour/ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <url> <dir>
# 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

Expand All @@ -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

Expand All @@ -88,47 +45,54 @@ 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
COPY ./ui ${WORKING_DIR}/ui
RUN yarn cache clean
RUN yarn config delete proxy
RUN yarn config delete https-proxy
RUN yarn config delete registry
RUN yarn install --network-timeout 1000000
RUN yarn workspace cap-react build

RUN pwd
RUN yarn install
# RUN yarn upgrade
# # build docs general
# WORKDIR $WORKING_DIR/docs

RUN yarn workspace cap-react build
RUN pwd
RUN ls ./cap-react/dist/*
RUN cp -rfp ./cap-react/dist/* $NGINX_HTML_DIR
# RUN yarn install
# RUN yarn build

# RUN mkdir -p $NGINX_HTML_DIR/docs/general
# RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general

# build docs general
WORKDIR $WORKING_DIR/docs

RUN yarn
RUN yarn build
# # 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 mkdir -p $NGINX_HTML_DIR/docs/general
RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general
# 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

# 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
# # build docs client
# RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/
# WORKDIR $WORKING_DIR/cap-client/docs

RUN mkdir -p $NGINX_HTML_DIR/docs/api
RUN cp -rfp ./web_deploy/* $NGINX_HTML_DIR/docs/api
# RUN yarn
# RUN yarn build

# RUN mkdir -p $NGINX_HTML_DIR/docs/client
# RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/client

# build docs client
RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/
WORKDIR $WORKING_DIR/cap-client/docs
FROM nginx:1.24

RUN yarn
RUN yarn build
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

0 comments on commit a695479

Please sign in to comment.