部署到 Fargate 时找不到入口点。本地作品

Entrypoint not found when deployed to Fargate. Locally works

我有以下 Dockerfile,目前在我的设备本地工作:

FROM python:3.7-slim-buster

WORKDIR /app

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["sh", "-c", "./entrypoint.sh"]

但是当我将它部署到 Fargate 时,容器在达到稳定状态之前停止:

sh: 1: ./entrypoint.sh: 未找到

编辑:添加 entrypoint.sh 文件进行说明:

#!/bin/env sh
# start process, but it should exit once the file is in S3
/app/cat/sitemap_download.py
# Once the process is done, we are good to scale down the service
aws ecs update-service --cluster cluster_name --region eu-west-1 --service service-name --desired-count 0

我已经尝试修改 ENTRYPOINT 以将其用作 exec 形式或完整路径,但总是遇到同样的问题。关于我做错了什么有什么想法吗?

我现在已经成功修复了。

将 Dockerfile 更改为如下所示解决了问题:

COPY . /app

VOLUME /app

RUN chmod +x /app/cat/sitemap_download.py

COPY entrypoint.sh /app/entrypoint.sh

RUN chmod +x /app/entrypoint.sh

ARG VERSION=3.7.4

RUN apt update && \
       apt install -y bash wget && \
       wget -O /tmp/nordrepo.deb https://repo.nordvpn.com/deb/nordvpn/debian/pool/main/nordvpn-release_1.0.0_all.deb && \
       apt install -y /tmp/nordrepo.deb && \
       apt update && \
       apt install -y nordvpn=$VERSION && \
       apt remove -y wget nordvpn-release

RUN apt-get clean \
    && apt-get -y update
RUN apt-get -y install python3-dev \
    python3-psycopg2 \
    && apt-get -y install build-essential

RUN pip install --upgrade pip

RUN pip install -r cat/requirements.txt

RUN pip install awscli

ENTRYPOINT ["/bin/bash"]
CMD ["./entrypoint.sh"]

我在阅读后尝试了这个:What is the difference between CMD and ENTRYPOINT in a Dockerfile?

我相信这个语法修复了它,因为对于入口点,我在开始时指示 bash 为 运行,然后将脚本作为参数传递。