mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Add poetry as CI container build dependency
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.
This commit is contained in:
parent
80db7bb02e
commit
773fcfa75b
4 changed files with 26 additions and 13 deletions
|
@ -95,23 +95,27 @@ jobs:
|
||||||
command: ./dev_scripts/qa.py --check-refs
|
command: ./dev_scripts/qa.py --check-refs
|
||||||
|
|
||||||
build-container-image:
|
build-container-image:
|
||||||
working_directory: /app
|
machine:
|
||||||
docker:
|
image: ubuntu-2004:202111-01
|
||||||
- image: docker:dind
|
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
|
- run: *install-podman
|
||||||
|
- run:
|
||||||
|
name: Prepare cache directory
|
||||||
|
command: |
|
||||||
|
sudo mkdir -p /caches
|
||||||
|
sudo chown -R $USER:$USER /caches
|
||||||
- run: *calculate-cache-key
|
- run: *calculate-cache-key
|
||||||
- restore_cache: *restore-cache
|
- restore_cache: *restore-cache
|
||||||
- setup_remote_docker
|
# setup_remote_docker
|
||||||
- run:
|
- run:
|
||||||
name: Build Dangerzone image
|
name: Build Dangerzone image
|
||||||
command: |
|
command: |
|
||||||
if [ -f "/caches/container.tar.gz" ]; then
|
if [ -f "/caches/container.tar.gz" ]; then
|
||||||
echo "Already cached, skipping"
|
echo "Already cached, skipping"
|
||||||
else
|
else
|
||||||
docker build dangerzone/ -f Dockerfile \
|
sudo pip3 install poetry
|
||||||
--cache-from=dangerzone.rocks/dangerzone \
|
python3 ./install/common/build-image.py
|
||||||
--tag dangerzone.rocks/dangerzone
|
|
||||||
fi
|
fi
|
||||||
- run:
|
- run:
|
||||||
name: Save Dangerzone image and image-id.txt to cache
|
name: Save Dangerzone image and image-id.txt to cache
|
||||||
|
@ -120,9 +124,9 @@ jobs:
|
||||||
echo "Already cached, skipping"
|
echo "Already cached, skipping"
|
||||||
else
|
else
|
||||||
mkdir -p /caches
|
mkdir -p /caches
|
||||||
docker save -o /caches/container.tar dangerzone.rocks/dangerzone
|
podman save -o /caches/container.tar dangerzone.rocks/dangerzone
|
||||||
gzip -f /caches/container.tar
|
gzip -f /caches/container.tar
|
||||||
docker image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > /caches/image-id.txt
|
podman image ls dangerzone.rocks/dangerzone | grep "dangerzone.rocks/dangerzone" | tr -s ' ' | cut -d' ' -f3 > /caches/image-id.txt
|
||||||
fi
|
fi
|
||||||
- run: *calculate-cache-key
|
- run: *calculate-cache-key
|
||||||
- save_cache:
|
- save_cache:
|
||||||
|
|
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
|
@ -62,6 +62,9 @@ jobs:
|
||||||
--version ${{ env.version }} \
|
--version ${{ env.version }} \
|
||||||
build-dev
|
build-dev
|
||||||
|
|
||||||
|
- name: Install container build dependencies
|
||||||
|
run: sudo apt install pipx && pipx install poetry
|
||||||
|
|
||||||
- name: Build Dangerzone image
|
- name: Build Dangerzone image
|
||||||
run: python3 ./install/common/build-image.py
|
run: python3 ./install/common/build-image.py
|
||||||
|
|
||||||
|
|
4
.github/workflows/scan.yml
vendored
4
.github/workflows/scan.yml
vendored
|
@ -12,8 +12,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
- name: Install container build dependencies
|
||||||
|
run: sudo apt install pipx && pipx install poetry
|
||||||
- name: Build container image
|
- 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
|
# NOTE: Scan first without failing, else we won't be able to read the scan
|
||||||
# report.
|
# report.
|
||||||
- name: Scan container image (no fail)
|
- name: Scan container image (no fail)
|
||||||
|
|
|
@ -72,9 +72,13 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
def export_container_pip_dependencies():
|
def export_container_pip_dependencies():
|
||||||
container_requirements_txt = subprocess.check_output(
|
try:
|
||||||
["poetry", "export", "--only", "container"], universal_newlines=True
|
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
|
# XXX Export container dependencies and exclude pymupdfb since it is not needed in container
|
||||||
req_txt_pymupdfb_stripped = container_requirements_txt.split("pymupdfb")[0]
|
req_txt_pymupdfb_stripped = container_requirements_txt.split("pymupdfb")[0]
|
||||||
with open(Path(BUILD_CONTEXT) / REQUIREMENTS_TXT, "w") as f:
|
with open(Path(BUILD_CONTEXT) / REQUIREMENTS_TXT, "w") as f:
|
||||||
|
|
Loading…
Reference in a new issue