在本地与Dockerfile一起工作:
FROM archlinux:latest
RUN pacman -Syu make cmake gcc base-devel --noconfirm
RUN useradd build
bash:和
cmake CMakeLists.txt
cmake --build .
makepkg
和
docker build -t build .
docker run -v "$PWD" --user build -w "/app" build ./build.sh
在本地所有工作正常,但与github工作
name: archlinux build
on: [push]
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v3
- name: Build
run: docker build -t build . && docker run -v "$PWD" --user build -w "/app" build ./build.sh
job failed with error:
CMake Error: Unable to (re)create the private pkgRedirects directory:
/app/CMakeFiles/pkgRedirects
Error: could not load cache
==> ERROR: You do not have write permission for the directory $BUILDDIR (/app).
Aborting...
我试图检查创建文件的问题是什么,而不是cmake我插入touch test
。由于访问问题,触摸也拒绝运行。如何使github工作流中的文件可以在docker容器内创建?
问题是工作流是作为用户的根用户运行的,而makepkg需要一个不同的用户。将run替换为。/ci_build.sh,增加了chmod,一切正常。ci_build.sh:
chmod 777 . -R
docker build -t build . && docker run -v "$PWD" --user build -w "/app"
build ./build.sh