Currently I am trying to implement a contianer into my Github Actions workflow. However I am having difficulties figuring out how to run steps in the container itself.
The following workflow is used:
name: Laravel
on: pull_request
jobs:
laravel-checks:
runs-on: ubuntu-latest
container: thomasowow/laravel-php:7.4
steps:
- uses: actions/checkout@v2
- name: Yarn
run: |
yarn
This workflow results in the following error:
/__w/_temp/c399fe7d-6cd2-4cdc-bb06-acc829cddbb8.sh: 1: /__w/_temp/c399fe7d-6cd2-4cdc-bb06-acc829cddbb8.sh: yarn: not found
##[error]Process completed with exit code 127
It is unable to find yarn
. The thomasowow/laravel-php:7.4
runs locally with yarn
available. I have tested this with other things that should be avilable in the docker image and they were not found either. It looks like the steps are not being executed in the container.
The documentation states the following for the jobs.<job_id>.container
syntax:
A container to run any steps in a job that don't already specify a container
I know there are solutions that work without using a container, I would prefer to use it.
Anybody had the same issue or knows what I am doing wrong?
Solution
@DannyB pointed out that my image contains the following entrypoint:
["/bin/bash", "--login", "-c", "tail -f /dev/null"]
This might have been the cause of Github not being able to run things in the container properly.
They were required in the image to install nvm, node and yarn
SHELL ["/bin/bash", "--login", "-c"]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
RUN nvm install 12.18.3
RUN npm install -g yarn
CMD ["/bin/bash"]
Removing SHELL
to RUN npm ...
solved the issue and Github was able again to run things in the container properly.
Currently I am still unable to install yarn without my old solution, but I think there are other ways to do this. Anybody suggestions how to do this in a clean way?
Installing node and yarn
I was able to get node
and yarn
installed using this answer.
ENV NODE_VERSION=12.18.3
RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
ENV NVM_DIR=/root/.nvm
RUN . "$NVM_DIR/nvm.sh" && nvm install ${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm use v${NODE_VERSION}
RUN . "$NVM_DIR/nvm.sh" && nvm alias default v${NODE_VERSION}
ENV PATH="/root/.nvm/versions/node/v${NODE_VERSION}/bin/:${PATH}"
RUN npm install -g yarn
Some attempts were made to COPY
from the office Node docker images. With this solution I was able to get node
working. npm
and yarn
were also running but with errors.
COPY --from=node:12.18.3 /usr/local/bin/node /usr/bin/node
...