Skip to content

Commit

Permalink
Merge pull request #69 from jkandasa/sync_gh_action_1.14.x
Browse files Browse the repository at this point in the history
SRVKP-4116: [v1.14.0] sync github actions and docker changes with main branch
  • Loading branch information
openshift-merge-bot[bot] committed Feb 13, 2024
2 parents 0295556 + 1f6c7bb commit 2409c4d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/publish_container_image.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: publish container images
on:
push:
branches: [main]
branches:
- main
- release-v* # example: release-v1.14
tags: ['v*']

jobs:
setup:
name: Setup
name: build container
runs-on: ubuntu-latest

steps:
Expand All @@ -26,8 +28,17 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: |
**/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}

- name: Build and push Dynamic Console container image
run: ./build.sh
run: ./scripts/build_container.sh
env:
SUPPORT_MULTI_ARCH: "true"
CONSOLE_PLUGIN_IMAGE_REPO: 'ghcr.io/${{ github.repository }}'
Expand Down
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM registry.access.redhat.com/ubi8/nodejs-16:latest AS build
FROM registry.access.redhat.com/ubi8/nodejs-16:latest AS builder-ui
USER root
RUN command -v yarn || npm i -g yarn

ADD . /usr/src/app
WORKDIR /usr/src/app
RUN yarn install && yarn build

RUN yarn install --frozen-lockfile && \
yarn build

FROM registry.access.redhat.com/ubi8/nginx-120:latest

COPY --from=build /usr/src/app/dist /usr/share/nginx/html
COPY --from=builder-ui /usr/src/app/dist /usr/share/nginx/html

COPY ./nginx.conf /etc/nginx/nginx.conf

Expand Down
18 changes: 18 additions & 0 deletions Dockerfile.without_builder
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# used to generate multiarch container image

# performing "yarn install" on multiarch with "docker buildx" takes a lot of time
# to avoid this, "yarn install" and "yarn build" should be executed outside of docker
# and only copy the "dist" to different platform/architecture runtime containers
# WARNING: with this approach, if we use platform naive package may lead to a malfunction
# however in this project, the code will be executed on a browser,
# hence assuming no impact on this approach

FROM registry.access.redhat.com/ubi8/nginx-120:latest

COPY ./dist /usr/share/nginx/html

COPY ./nginx.conf /etc/nginx/nginx.conf

USER 1001

ENTRYPOINT ["nginx", "-g", "daemon off;"]
13 changes: 12 additions & 1 deletion build.sh → scripts/build_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ echo "Building the Console Plugin Image: ${CONSOLE_PLUGIN_IMAGE}"

# builds multi arch images
if [ "$SUPPORT_MULTI_ARCH" = "true" ]; then
# performing "yarn install" on multiarch with "docker buildx" takes a lot of time
# to avoid this, "yarn install" and "yarn build" should be executed outside of docker
# and only copy the "dist" to different platform/architecture runtime containers
# WARNING: with this approach, if we use platform naive package may lead to a malfunction
# however in this project, the code will be executed on a browser,
# hence assuming no impact on this approach
yarn install --frozen-lockfile
yarn build

docker buildx build --push \
--progress=plain \
--platform "linux/amd64,linux/arm64,linux/ppc64le,linux/s390x" \
--file ./Dockerfile.without_builder \
--tag ${CONSOLE_PLUGIN_IMAGE} .

else # build platform specific image
${CONTAINER_RUNTIME} build --tag ${CONSOLE_PLUGIN_IMAGE} .
${CONTAINER_RUNTIME} build --file ./Dockerfile --tag ${CONSOLE_PLUGIN_IMAGE} .
${CONTAINER_RUNTIME} push ${CONSOLE_PLUGIN_IMAGE}
fi

0 comments on commit 2409c4d

Please sign in to comment.