docker - Github 操作 Pylint 步骤无法使用测试作业创建目录

标签 docker github-actions pylint fastapi

我实际上是在尝试使用 CI/CD 和 Heroku 部署完成我的第一个 GitHub 操作,但我收到此错误。
错误图像:
enter image description here
这是我的公开 repo 。
https://github.com/jovicon/the_empire_strikes_back_challenge
一切都在“开发”分支中更新
这是我的测试工作: (full file)
注意:当我评论时 Pylint 步骤 一切正常。

test:
    name: Test Docker Image
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Checkout master
        uses: actions/checkout@v1
      - name: Log in to GitHub Packages
        run: echo ${GITHUB_TOKEN} | docker login -u ${GITHUB_ACTOR} --password-stdin docker.pkg.github.com
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      - name: Pull image
        run: |
          docker pull ${{ env.IMAGE }}:latest || true
      - name: Build image
        run: |
          docker build \
            --cache-from ${{ env.IMAGE }}:latest \
            --tag ${{ env.IMAGE }}:latest \
            --file ./backend/Dockerfile.prod \
            "./backend"
      - name: Run container
        run: |
          docker run \
            -d \
            --name fastapi-tdd \
            -e PORT=8765 \
            -e ENVIRONMENT=dev \
            -e DATABASE_TEST_URL=sqlite://sqlite.db \
            -p 5003:8765 \
            ${{ env.IMAGE }}:latest
      - name: Pytest
        run: docker exec fastapi-tdd python -m pytest .
      - name: Pylint
        run: docker exec fastapi-tdd python -m pylint app/
      - name: Black
        run: docker exec fastapi-tdd python -m black . --check
      - name: isort
        run: docker exec fastapi-tdd /bin/sh -c "python -m isort ./*/*.py --check-only"
我把我的 放在这里Dockerfile.prod 也:
# pull official base image
FROM python:3.8.3-slim-buster

# create directory for the app user
RUN mkdir -p /home/app

# create the app user
RUN addgroup --system app && adduser --system --group app

# create the appropriate directories
ENV HOME=/home/app
ENV APP_HOME=/home/app/web
RUN mkdir $APP_HOME
WORKDIR $APP_HOME

# set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV ENVIRONMENT prod
ENV TESTING 0

# install system dependencies
RUN apt-get update \
    && apt-get -y install netcat gcc postgresql \
    && apt-get clean

# install python dependencies
RUN pip install --upgrade pip
COPY ./requirements.txt .
COPY ./dev-requirements.txt .
RUN pip install -r requirements.txt
RUN pip install -r dev-requirements.txt

# add app
COPY . .

RUN chmod 755 $HOME

# chown all the files to the app user
RUN chown -R app:app $APP_HOME

# change to the app user
USER app

# run gunicorn
CMD gunicorn --bind 0.0.0.0:$PORT app.main:app -k uvicorn.workers.UvicornWorker

最佳答案

您正在设置 $HOME默认用户的目录权限为 755。 chown -R app:app $APP_HOME仅目标 $APP_HOME ,它只是 $HOME 的子目录.
结果,用户app没有对 $HOME 的写权限并且 pylint 无法创建目录 /home/app/.pylint.d .

关于docker - Github 操作 Pylint 步骤无法使用测试作业创建目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64219080/

相关文章:

docker - 如何找到Dockerfile中的哪一步添加了一些路径?

c - 使用cgroup_new_cgroup创建cgroup时出现错误50007

GitHub 操作 "extend"现有作业

python - Docker 开发环境,pylint 无法导入错误

python - Pylint 错误 E1128 背后的逻辑(无分配)

docker - vscode 打开 devcontainer 时如何自动运行 cmd?

docker - 使用 docker 安装 java 8 的最佳方法?

docker - GitHub Actions工作流错误: Permission denied

azure - 在禁用公共(public)访问的情况下压缩部署 Azure 函数(存在访问限制)

visual-studio-code - 如何在 VS Code 中启用 "too-many-locals"Pylint 消息?