找不到指定的Dockerfile:上下文/ Dockerfile-管道Bitbucket

时间:2019-06-29 08:57:50

标签: docker docker-compose dockerfile bitbucket pipeline

我正在尝试为我的React项目设置一个位桶管道。为此,我创建了一个docker-compose文件和一个Dockerfile。

这是我的管道文件:

  branches:
    develop:
      - step:
          name: Dockerize
          script:
            - docker login $DOCKER_REGISTRY -u $DOCKER_REGISTRY_LOGIN -p $DOCKER_REGISTRY_PWD
            - docker build -f context/Dockerfile -t $DOCKER_IMAGE_NAME --build-arg BASE_API_URL=$API_DEV_URL .
            - docker tag $DOCKER_IMAGE_NAME $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
            - docker push $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
          services:
            - docker
          caches:
            - docker
      - step:
          name: Deploy to dev
          deployment: dev
          script:
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER rm -Rf $DOCKER_COMPOSE_DEV_PATH/*
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER mkdir $DOCKER_COMPOSE_DEV_PATH/log
            - scp -P $SERVER_PORT docker-compose.yml $SERVER_USER@$SERVER:$DOCKER_COMPOSE_DEV_PATH/
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER docker pull $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER docker tag $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT $DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER docker rmi $DOCKER_REGISTRY/$DOCKER_IMAGE_NAME:$BITBUCKET_COMMIT
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER TAG=$BITBUCKET_COMMIT docker-compose -p container-name -f $DOCKER_COMPOSE_DEV_PATH/docker-compose.yml down
            - ssh -p $SERVER_PORT $SERVER_USER@$SERVER TAG=$BITBUCKET_COMMIT docker-compose -p container-name -f $DOCKER_COMPOSE_DEV_PATH/docker-compose.yml up -d

options:
  docker: true

这是我的docker-compose文件

version: '3'

services:
  image_name:
    image: repo/image_name:${TAG}
    build:
      context: .
      dockerfile: context/Dockerfile
      args:
        - BASE_API_URL=${BASE_API_URL}
    volumes:
      - ./log:/var/log/nginx/

我的文件树如下

-app
|_ bitbucket-pipeline.yml
|_ docker-compose.yml
|_ context
  |_ Dockerfile

从我的阅读中,我看不到我的docker-compose文件有问题。我的上下文和dockerfile参考应该可以工作。但是我最终在管道的最后一步(即,在运行docker-compose up命令时)遇到错误Cannot locate specified Dockerfile: context/Dockerfile

我不知道要进行哪些更改才能使其正常工作。

1 个答案:

答案 0 :(得分:0)

尝试一下:

docker build -f context/Dockerfile -t $DOCKER_IMAGE_NAME --build-arg BASE_API_URL=$API_DEV_URL ./context