Skip to content
Snippets Groups Projects
Commit a775792a authored by William Di Luigi's avatar William Di Luigi
Browse files

Optimize docker build time

Split `docker build` and `docker run` in two separate workflow steps
to reduce the output size in the github action and make it more readable

Also improve the docker (re)build speed by better using the cache: we
first copy the requirements.txt, then install, then copy the rest of the
folder, which means we won't invalidate the cached `pip install` step
unless we really need to
parent 152501ca
No related branches found
No related tags found
No related merge requests found
...@@ -17,9 +17,13 @@ jobs: ...@@ -17,9 +17,13 @@ jobs:
run: | run: |
mount | grep cgroup mount | grep cgroup
- name: Build docker image
run: |
docker-compose -f docker-compose.test.yml build cms_test
- name: Run tests - name: Run tests
run: | run: |
docker-compose -f docker-compose.test.yml run cms_test docker-compose -f docker-compose.test.yml run --rm cms_test
- uses: codecov/codecov-action@v3 - uses: codecov/codecov-action@v3
with: with:
... ...
......
...@@ -35,12 +35,16 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers ...@@ -35,12 +35,16 @@ RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
# Set cmsuser as default user # Set cmsuser as default user
USER cmsuser USER cmsuser
COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms RUN mkdir /home/cmsuser/cms
COPY --chown=cmsuser:cmsuser requirements.txt dev-requirements.txt /home/cmsuser/cms/
WORKDIR /home/cmsuser/cms WORKDIR /home/cmsuser/cms
RUN sudo pip3 install -r requirements.txt RUN sudo pip3 install -r requirements.txt
RUN sudo pip3 install -r dev-requirements.txt RUN sudo pip3 install -r dev-requirements.txt
COPY --chown=cmsuser:cmsuser . /home/cmsuser/cms
RUN sudo python3 setup.py install RUN sudo python3 setup.py install
RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install RUN sudo python3 prerequisites.py --yes --cmsuser=cmsuser install
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment