Skip to content

Commit

Permalink
Add poetry as CI container build dependency
Browse files Browse the repository at this point in the history
Due to the new build-image.py, which now uses `poetry export` we need to
explicitly install poetry in the CI before building the container image.
  • Loading branch information
deeplow committed Dec 20, 2023
1 parent 75d4098 commit c383dbb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
22 changes: 11 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,34 @@ jobs:
command: ./dev_scripts/qa.py --check-refs

build-container-image:
working_directory: /app
docker:
- image: docker:dind
machine:
image: ubuntu-2004:202111-01
steps:
- checkout
- run: *install-podman
- run: *calculate-cache-key
- restore_cache: *restore-cache
- setup_remote_docker
# setup_remote_docker
- run:
name: Build Dangerzone image
command: |
if [ -f "/caches/container.tar.gz" ]; then
echo "Already cached, skipping"
else
docker build dangerzone/ -f Dockerfile \
--cache-from=dangerzone.rocks/dangerzone \
--tag dangerzone.rocks/dangerzone
sudo apt install -y pipx
pipx install poetry
python3 ./install/common/build-image.py
fi
- run:
name: Save Dangerzone image and image-id.txt to cache
command: |
if [ -f "/caches/container.tar.gz" ]; then
echo "Already cached, skipping"
else
mkdir -p /caches
docker save -o /caches/container.tar dangerzone.rocks/dangerzone
gzip -f /caches/container.tar
docker image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > /caches/image-id.txt
sudo mkdir -p /caches
sudo podman save -o /caches/container.tar dangerzone.rocks/dangerzone
sudo gzip -f /caches/container.tar
podman image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 | sudo tee /caches/image-id.txt
fi
- run: *calculate-cache-key
- save_cache:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ jobs:
--version ${{ env.version }} \
build-dev
- name: Install container build dependencies
run: sudo apt install pipx && pipx install poetry

- name: Build Dangerzone image
run: python3 ./install/common/build-image.py

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install container build dependencies
run: sudo apt install pipx && pipx install poetry
- name: Build container image
run: docker build dangerzone/ -f Dockerfile --tag dangerzone.rocks/dangerzone:latest
run: python3 ./install/common/build-image.py
# NOTE: Scan first without failing, else we won't be able to read the scan
# report.
- name: Scan container image (no fail)
Expand Down
10 changes: 7 additions & 3 deletions install/common/build-image.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@ def main():


def export_container_pip_dependencies():
container_requirements_txt = subprocess.check_output(
["poetry", "export", "--only", "container"], universal_newlines=True
)
try:
container_requirements_txt = subprocess.check_output(
["poetry", "export", "--only", "container"], universal_newlines=True
)
except subprocess.CalledProcessError as e:
print("FAILURE", e.returncode, e.output)
print(f"REQUIREMENTS: {container_requirements_txt}")
# XXX Export container dependencies and exclude pymupdfb since it is not needed in container
req_txt_pymupdfb_stripped = container_requirements_txt.split("pymupdfb")[0]
with open(Path(BUILD_CONTEXT) / REQUIREMENTS_TXT, "w") as f:
Expand Down

0 comments on commit c383dbb

Please sign in to comment.