I'm going through the course "Scalable FastAPI Applications on AWS and Docker" from testdriven.io, but with a little challenge by using GitHub Actions instead of Gitlab CI.
In the Part 1 -> Tests and Code Quality part, there is something that I don't understand.
More precisely, in the "Code Quality Checks" part.
Here is the content of the service-talk-booking-code-quality
job :
service-talk-booking-code-quality:
stage: test
image: registry.gitlab.com/<your-gitlab-username>/talk-booking:cicd-python3.11-slim
before_script:
- cd services/talk_booking/
- poetry install
script:
- poetry run flake8 .
- poetry run black . --check
- poetry run isort . --check-only --profile black
- poetry run bandit .
- poetry run safety check
And the Dockerfile of the docker container that is running this job :
FROM python:3.11-slim
RUN mkdir -p /home/gitlab && addgroup gitlab && useradd -d /home/gitlab -g gitlab gitlab && chown gitlab:gitlab /home/gitlab
RUN apt-get update && apt-get install -y curl
USER gitlab
WORKDIR /home/gitlab
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH=/home/gitlab/.local/bin:$PATH
RUN poetry config virtualenvs.in-project true
When running cd / && ls -Rla
in the container when using it through GitHub , here is what I see :
2024-01-26T21:08:23.7347494Z ./__w/talk-booking:
2024-01-26T21:08:23.7347603Z total 12
2024-01-26T21:08:23.7347847Z drwxr-xr-x 3 1001 127 4096 Jan 26 21:08 .
2024-01-26T21:08:23.7348076Z drwxr-xr-x 6 1001 root 4096 Jan 26 21:08 ..
2024-01-26T21:08:23.7348380Z drwxr-xr-x 2 1001 127 4096 Jan 26 21:08 talk-booking
2024-01-26T21:08:23.7348387Z
2024-01-26T21:08:23.7348582Z ./__w/talk-booking/talk-booking:
2024-01-26T21:08:23.7348704Z total 8
2024-01-26T21:08:23.7348920Z drwxr-xr-x 2 1001 127 4096 Jan 26 21:08 .
2024-01-26T21:08:23.7349137Z drwxr-xr-x 3 1001 127 4096 Jan 26 21:08 ..
There is a talk-booking
directory, but it is empty which causes poetry
to not work in my GitHub actions.
In the course, how is there a services/talk_booking/
folder in the container since it was not copied in the Dockerfile?
My first guess would be to simply add a COPY
step in the Dockerfile, but I think there is a reason there is none in the provided file.
OK, I got it.
Turns out I needed to :
- name: Checkout Repository
uses: actions/checkout@main
container:
image: kernju/my-image
options: --user root