I started the pipeline through the gitlab-runner run command on ther server, but in gitlab CI/CD > Jobs, an error is occurring in the ‘build image’ stage.
When building an image, I manage the base image and the custom image separately. and this is offline environment. Base image is directly inputted by command below to build
- podman build -t react-base-nodev18:14-alpine:init -f Dockerfile.base
(Here, yarn install succeeded successfully.) - podman tag localhost/react-base-nodev18.14-alpine:init image-registry.apps.{url}.com/fep/react-base-nodev18.14-alpine:init
- oc login … (omit)
4.podman push image-registry.apps.{url}.com/fep/react-base-nodev18.4-alpine:init - gitlab-runner run
and then I found the error below
STEP 5/7: RUN yarn run build
yarn run v1.22.19
react-script-build
Creating an optiomized production build...
Failed to compile.
Module not found: Error: Can't resolve '@mui/material' in '/app/src/components'
error Command failed with exit code 1
Error: error building at STEP "RUN yarn run build": error while running runtime"exit staus1
Here’s the file content.
dockerfile.base
FROM image-registry.apps.{url}.com/fep/react-base-nodev18.14-alpine:init
WORKDIR /app
COPY src ./src
COPY public ./public
RUN yarn run build
EXPOSE 3000
CMD ["yarn", "serve", "build"]
dockerfile
FROM image-registry.apps.{url}.com/fep/react-base-nodev18.14-alpine:init
WORKDIR /app
COPY . .
COPY src ./src
COPY public ./public
EXPOSE 3000
CMD ["yarn", "serve", "build"]
.gitlab-ci.yml
before_script:
- source_%FEP_ADMIN_FRONT_FILE
stages:
- set-version
- pr-check
- build-image
- tag-image
- push-image
- deploy
variables:
FEP_ADMIN_FRONT_FILE: ./variables
FEP_ADMIN_FRONT_APP: fep_admin_frontend
set-version:
stage: set-version
before-script:
- echo "setting version via package.json!"
script:
- FEP_ADMIN_FRONT_VER=${jq -r .version package.json}
- echo "export FEP_ADMIN_FRONT_VER=$FEP_ADMIN_FRONT_VER" > $FEP_ADMIN_FRONT_FILE
artifacts:
paths:
- $FEP_ADMIN_FRONT_FILE
pr-check:
stage: pr-ceck
before_script:
- oc login -u {//login info}
- podmain login -u {//login info}
build-image
stage: build-image
script:
- podman build -t $FEP_ADMIN_FRONT_APP:$FEP_ADMIN_FRONT_VER .
(... omission)
I’ve spent weeks trying to solve this problem, but I haven’t. Your little advice will be of great help. Thank you so much for reading.