Skip to content

Commit 055af51

Browse files
committed
devops: fix harbor build action
Signed-off-by: Miguel Garcia Garcia <[email protected]>
1 parent 34e718c commit 055af51

File tree

5 files changed

+38
-27670
lines changed

5 files changed

+38
-27670
lines changed

.github/workflows/harbour-build-ui.yml

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ name: Build and export CAP UI image
22

33
on:
44
push:
5-
branches: ['master', 'dev', 'qa', 'test']
6-
paths:
7-
- "ui/**"
8-
- ".github/workflows/ui-test.yml"
5+
branches: ["master", "dev", "qa", "test", "with-formule"]
6+
# paths:
7+
# - "ui/**"
8+
# - ".github/workflows/ui-test.yml"
99

1010
jobs:
1111
build-image:
12-
needs: UITest
1312
name: Build and export ui image
1413
runs-on: ubuntu-20.04
1514
outputs:
@@ -43,39 +42,3 @@ jobs:
4342
CAP_PIWIK_SITEID_PROD=${{ secrets.CAP_PIWIK_SITEID_PROD }}
4443
CAP_PIWIK_SITEID_QA=${{ secrets.CAP_PIWIK_SITEID_QA }}
4544
CAP_PIWIK_SITEID_TEST=${{ secrets.CAP_PIWIK_SITEID_TEST }}
46-
47-
- id: build-ui-e2e
48-
name: Build and export for end to end image
49-
uses: cern-sis/gh-workflows/.github/actions/[email protected]
50-
if: ${{ steps.get_branch.outputs.BRANCH_NAME }} == 'qa'
51-
with:
52-
dockerfile: ./docker/harbour/ui/Dockerfile
53-
platforms: linux/amd64,linux/arm64
54-
image: cern-sis/cap-ui
55-
registry: registry.cern.ch
56-
cache: false
57-
tags: qa-e2e
58-
username: ${{ secrets.HARBOR_USERNAME }}
59-
password: ${{ secrets.HARBOR_PASSWORD }}
60-
build-args: |
61-
BRANCH_NAME=${{ steps.get_branch.outputs.BRANCH_NAME }}
62-
ENABLE_E2E=True
63-
PIWIK_ENV=${{ steps.get_branch.outputs.BRANCH_NAME }}
64-
CAP_PIWIK_URL=${{ secrets.CAP_PIWIK_URL }}
65-
CAP_PIWIK_SITEID_QA=${{ secrets.CAP_PIWIK_SITEID_QA }}
66-
67-
deploy:
68-
needs: build-image
69-
name: update-image
70-
runs-on: ubuntu-20.04
71-
72-
steps:
73-
- name: send event
74-
uses: cern-sis/gh-workflows/.github/actions/[email protected]
75-
with:
76-
event-type: update
77-
token: ${{ secrets.PAT_FIRE_EVENTS_ON_CERN_SIS_KUBERNETES_CAP }}
78-
repo: cern-sis/kubernetes-cap
79-
images: |
80-
cern-sis/cap-ui@{{ needs.build-image.outputs.image-id }}
81-

docker/harbour/ui/Dockerfile

Lines changed: 34 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,10 @@
1-
FROM nginx:1.24
2-
3-
4-
RUN apt-get update
5-
RUN apt-get install -y curl bash
6-
7-
8-
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
9-
RUN apt-get install -y nodejs
1+
FROM node:18-alpine as build
102

11-
RUN apt-get update && apt-get -y install git python g++ make
12-
RUN npm install --global yarn
3+
RUN apk add --no-cache git
134

145
ENV WORKING_DIR=/tmp/cap
15-
ENV NGINX_HTML_DIR=/usr/share/nginx/html
16-
ENV NODE_OPTIONS="--max-old-space-size=8192"
17-
18-
RUN mkdir -p $NGINX_HTML_DIR
19-
20-
# We invalidate cache always because there is no easy way for now to detect
21-
# if something in the whole git repo changed. For docker git clone <url> <dir>
22-
# is always the same so it caches it.
23-
ARG CACHE_DATE=$(date)
24-
25-
# get the code at a specific commit
26-
RUN git clone https://github.com/cernanalysispreservation/analysispreservation.cern.ch.git $WORKING_DIR/
27-
28-
WORKDIR $WORKING_DIR/
296

30-
ARG BRANCH_NAME
31-
32-
RUN echo $BRANCH_NAME
33-
34-
RUN git fetch --all
35-
36-
RUN if [ ! -z $BRANCH_NAME ]; then \
37-
# run commands to checkout a branch
38-
echo "Checkout branch $BRANCH_NAME" && \
39-
git checkout $BRANCH_NAME && \
40-
git pull origin $BRANCH_NAME; \
41-
fi
42-
43-
RUN git log -10 --pretty=oneline --decorate
44-
45-
RUN cp -rfp $WORKING_DIR/docker/nginx/nginx.conf /etc/nginx/nginx.conf
46-
47-
WORKDIR $WORKING_DIR/ui
7+
WORKDIR $WORKING_DIR
488

499
ARG PIWIK_ENV=dev
5010
ARG ENABLE_E2E
@@ -61,74 +21,68 @@ ARG PIWIK_SITEID_PROD
6121
ARG PIWIK_SITEID_QA
6222
ARG PIWIK_SITEID_TEST
6323

64-
RUN echo "" >> $WORKING_DIR/ui/cap-react/.env
65-
RUN echo "" >> $WORKING_DIR/ui/cap-react/.env
66-
RUN echo "PIWIK_URL=$CAP_PIWIK_URL" >> $WORKING_DIR/ui/cap-react/.env
67-
RUN echo "ENABLE_E2E=$ENABLE_E2E" >> $WORKING_DIR/ui/cap-react/.env
68-
69-
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
24+
RUN mkdir -p ui/cap-react
25+
RUN echo "PIWIK_URL=$CAP_PIWIK_URL" >> ui/cap-react/.env
26+
RUN echo "ENABLE_E2E=$ENABLE_E2E" >> ui/cap-react/.env
7027

7128
RUN if [[ $PIWIK_ENV == "dev" ]]; then \
72-
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_DEV" >> $WORKING_DIR/ui/cap-react/.env; \
29+
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_DEV" >> ui/cap-react/.env; \
7330
fi
7431

7532
RUN if [[ $PIWIK_ENV == "prod" ]]; then \
76-
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_PROD" >> $WORKING_DIR/ui/cap-react/.env; \
33+
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_PROD" >> ui/cap-react/.env; \
7734
fi
7835

7936
RUN if [[ $PIWIK_ENV == "qa" ]]; then \
80-
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_QA" >> $WORKING_DIR/ui/cap-react/.env; \
37+
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_QA" >> ui/cap-react/.env; \
8138
fi
8239

8340
RUN if [[ $PIWIK_ENV == "test" ]]; then \
84-
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_TEST" >> $WORKING_DIR/ui/cap-react/.env; \
41+
echo "PIWIK_SITEID=$CAP_PIWIK_SITEID_TEST" >> ui/cap-react/.env; \
8542
fi
8643

44+
8745
RUN echo "=========================="
8846
RUN echo $CAP_PIWIK_SITEID_TEST
8947
RUN echo $PIWIK_SITEID_TEST
9048
RUN echo "=========================="
91-
RUN less $WORKING_DIR/ui/cap-react/.env
49+
RUN cat ui/cap-react/.env
9250
RUN echo "=========================="
9351

94-
RUN yarn config set cache ~/.my-yarn-cache-dir
52+
WORKDIR $WORKING_DIR/ui
9553

96-
RUN pwd
54+
# build CAP UI
55+
COPY ./ui ${WORKING_DIR}/ui
9756
RUN yarn install
98-
# RUN yarn upgrade
99-
10057
RUN yarn workspace cap-react build
101-
RUN pwd
102-
RUN ls ./cap-react/dist/*
103-
RUN cp -rfp ./cap-react/dist/* $NGINX_HTML_DIR
10458

105-
# build docs general
59+
# build general docs
60+
COPY ./docs ${WORKING_DIR}/docs
10661
WORKDIR $WORKING_DIR/docs
107-
108-
RUN yarn
62+
RUN yarn install
10963
RUN yarn build
11064

111-
RUN mkdir -p $NGINX_HTML_DIR/docs/general
112-
RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/general
113-
114-
115-
# build docs API
65+
# build API docs
11666
RUN git clone https://github.com/cernanalysispreservation/cap-api-docs.git $WORKING_DIR/cap-api-docs/
11767
WORKDIR $WORKING_DIR/cap-api-docs
118-
119-
RUN npm install
68+
RUN npm install --maxsockets 1
12069
RUN npm run build
12170

122-
RUN mkdir -p $NGINX_HTML_DIR/docs/api
123-
RUN cp -rfp ./web_deploy/* $NGINX_HTML_DIR/docs/api
124-
125-
126-
# build docs client
71+
# build client docs
12772
RUN git clone https://github.com/cernanalysispreservation/cap-client.git $WORKING_DIR/cap-client/
12873
WORKDIR $WORKING_DIR/cap-client/docs
129-
130-
RUN yarn
74+
RUN yarn install
13175
RUN yarn build
13276

133-
RUN mkdir -p $NGINX_HTML_DIR/docs/client
134-
RUN cp -rfp ./_book/* $NGINX_HTML_DIR/docs/client
77+
78+
FROM nginx:1.24
79+
80+
ENV WORKING_DIR=/tmp/cap
81+
ENV NGINX_HTML_DIR=/usr/share/nginx/html/
82+
RUN mkdir -p $NGINX_HTML_DIR
83+
84+
COPY ./docker/nginx/nginx.conf /etc/nginx/nginx.conf
85+
COPY --from=build ${WORKING_DIR}/ui/cap-react/dist/ $NGINX_HTML_DIR
86+
COPY --from=build ${WORKING_DIR}/docs/_book/ $NGINX_HTML_DIR/docs/general
87+
COPY --from=build ${WORKING_DIR}/cap-api-docs/web_deploy/ $NGINX_HTML_DIR/docs/api
88+
COPY --from=build ${WORKING_DIR}/cap-client/docs/_book/ $NGINX_HTML_DIR/docs/client

docker/nginx/nginx.conf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ http {
6060
image/x-icon
6161
text/cache-manifest
6262
text/css
63-
text/html
6463
text/javascript
6564
text/plain
6665
text/vcard

0 commit comments

Comments
 (0)