如何使用Makefile将文件夹从父文件夹复制到Dockerfile的当前目录中

问题描述 投票:0回答:1

我有一个看起来像这样的makefile:

push:
    docker build -t dataengineering/dataloader .
    docker tag dataengineering/dataloader:latest 127579856528.dkr.ecr.us-west-2.amazonaws.com/dataengineering/dataloader:latest
    docker push 127579856528.dkr.ecr.us-west-2.amazonaws.com/dataengineering/dataloader:latest

deploy:
    @if [ ! "$(environment)" ]; then echo "environment must be defined"  && exit 1; fi
    @if [ ! "$(target)" ]; then echo "target must be defined"  && exit 1; fi
    kubectl delete deploy dataloader-$(target) -n dataengineering|| continue
    kubectl apply -f kube/$(environment)/deployment-$(target).yaml -n dataengineering

但是我需要在数据加载器中有一个文件夹,以便我的dockerfile能够正常工作。

这项工作吗?

push:
    cd ..; cp -r datastore/ dataloader/
    docker build -t dataengineering/dataloader .
    docker tag dataengineering/dataloader:latest 1111111111.dkr.ecr.us-west-2.amazonaws.com/dataengineering/dataloader:latest
    docker push 11111111111.dkr.ecr.us-west-2.amazonaws.com/dataengineering/dataloader:latest

deploy:
    @if [ ! "$(environment)" ]; then echo "environment must be defined"  && exit 1; fi
    @if [ ! "$(target)" ]; then echo "target must be defined"  && exit 1; fi
    kubectl delete deploy dataloader-$(target) -n dataengineering|| continue
    kubectl apply -f kube/$(environment)/deployment-$(target).yaml -n dataengineering

我的dockerfile:

FROM python:3.7

WORKDIR /var/dataloader

COPY assertions/ ./assertions/
...
COPY datastore/ ./datastore/

RUN pip3 install -r requirements.txt

ENTRYPOINT ["python", "dataloader.py"]
docker makefile
1个回答
1
投票

如果您只需要将目录复制到当前目录(将服务器作为Docker上下文),则可以使用cp -r ../datastore/ dataloader/。除非您希望dataloader目录与datastore目录位于同一目录中,否则您将执行cp -r ../datastore/ ../dataloader/

© www.soinside.com 2019 - 2024. All rights reserved.