chmod: cannot access ‘/opt/firefox/firefox’: Not a directory

  Kiến thức lập trình

I am using this Dockerfile via docker-compose

FROM python:3.9-slim-bullseye

ENV PYTHONDONTWRITEBYTECODE=1 
    PYTHONBUFFERED=1 
    GECKODRIVER_VER=v0.34.0 
    FIREFOX_VER=120.0

RUN apt-get update && apt-get install --no-install-recommends -y 
    gcc libc-dev libpq-dev  python-dev libxml2-dev libxslt1-dev python3-lxml curl unzip xvfb wget openssl bzip2 firefox-esr

# Add FireFox
RUN set -x 
   && apt install -y 
       libx11-xcb1 
       libdbus-glib-1-2

ADD distr/firefox-120.0.tar.bz2 /distr/firefox
RUN mv /distr/firefox /opt/            <--- ERROR ON THIS STEP
   && chmod 755 /opt/firefox 
   && chmod 755 /opt/firefox/firefox
  
# Add geckodriver
ADD distr/geckodriver-v0.34.0-linux64.tar.gz /distr/geckodriver
RUN mv /distr/geckodriver/geckodriver /usr/bin/ 
    && chmod 755 /usr/bin/geckodriver

WORKDIR /project
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .

The build is working fine on my PC, but in gitlab-CI I have an error:

chmod: cannot access ‘/opt/firefox/firefox’: Not a directory
The command ‘/bin/sh -c mv /distr/firefox /opt/ && chmod 755 /opt/firefox && chmod 755 /opt/firefox/firefox’ returned a non-zero code: 1

Build script in .gitlab-ci.yml

.build_template: &build
  stage: build
  variables:
    DOCKER_BUILD_OPTS: ''
    DOCKER_BUILD_CONTEXT: './project'
  script:
    - docker login -u ${HARBOR_USERNAME} -p ${HARBOR_PASSWORD} ${HARBOR_HOST} 2>&1
    - docker build ${DOCKER_BUILD_OPTS} -t ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} $DOCKER_BUILD_CONTEXT 2>&1
    - docker push ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} 2>&1
    - if [ ! -z ${CI_OPEN_MERGE_REQUESTS} ]; then export CI_COMMIT_BRANCH=$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME; fi
    - if [ "$CI_COMMIT_BRANCH" == "dev" ] || [ "$FORCE_BUILD" == "dev" ]; then
        export IMAGE_TAG=dev;
        echo -e "Image tag add: ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}" 2>&1;
        docker tag ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} 2>&1;
        docker push ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} 2>&1;
      fi
    - if [ "$CI_COMMIT_BRANCH" == "main" ] || [ "$FORCE_BUILD" == "latest" ]; then
        export IMAGE_TAG=latest;
        echo -e "Image tag add: ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG}" 2>&1;
        docker tag ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} 2>&1;
        docker push ${HARBOR_HOST}/${HARBOR_PROJECT}/${IMAGE_NAME}:${IMAGE_TAG} 2>&1;
      fi
  tags:
    - linux-shell

How to fix the error in gitlab-CI environment?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT