From 337b37362858df4202d23cad7c0242f1601d095c Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 24 Mar 2022 19:54:47 +0700 Subject: [PATCH] improve build to install debug tools in testing --- CONTRIBUTING.md | 2 +- Dockerfile | 8 ++++++++ deploy.sh | 12 ++++++------ tubearchivist/testing.sh | 9 --------- 4 files changed, 15 insertions(+), 16 deletions(-) delete mode 100644 tubearchivist/testing.sh diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8188766..06034d5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,7 +25,7 @@ This is my setup I have landed on, YMMV: ```bash ./deploy.sh test ``` -- The command above will also copy the file `tubarchivist/testing.sh` into the working folder of the container. Running this script will install additional debugging tools I regularly use in testing. +- The command above will call the docker build command with `--build-arg INSTALL_DEBUG=1` to install additional useful debug tools. - The `test` argument takes another optional argument to build for a specific architecture valid options are: `amd64`, `arm64` and `multi`, default is `amd64`. - This `deploy.sh` file is not meant to be universally usable for every possible environment but could serve as an idea on how to automatically rebuild containers to test changes - customize to your liking. diff --git a/Dockerfile b/Dockerfile index b5145d1..b009ec9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM python:3.10.2-slim-bullseye ARG TARGETPLATFORM +ARG INSTALL_DEBUG ENV PYTHONUNBUFFERED 1 @@ -26,6 +27,13 @@ RUN if [ "$TARGETPLATFORM" = "linux/amd64" ] ; then \ apt-get -y update && apt-get -y install --no-install-recommends ffmpeg && rm -rf /var/lib/apt/lists/* \ ; fi +# install debug tools for testing environment +RUN if [ "$INSTALL_DEBUG" ] ; then \ + apt-get -y update && apt-get -y install --no-install-recommends \ + vim htop bmon net-tools iputils-ping procps \ + && pip install --no-cache-dir ipython --src /usr/local/src \ + ; fi + # make folders RUN mkdir /cache RUN mkdir /youtube diff --git a/deploy.sh b/deploy.sh index 1af7865..26dd350 100755 --- a/deploy.sh +++ b/deploy.sh @@ -43,7 +43,10 @@ function sync_test { # pass argument to build for specific platform host="tubearchivist.local" + # make base folder + ssh "$host" "mkdir -p docker" + # copy project files to build image rsync -a --progress --delete-after \ --exclude ".git" \ --exclude ".gitignore" \ @@ -52,8 +55,8 @@ function sync_test { --exclude "db.sqlite3" \ . -e ssh "$host":tubearchivist - # uncomment or copy your own docker-compose file - # rsync -r --progress --delete docker-compose.yml -e ssh "$host":docker + # copy default docker-compose file if not exist + rsync --progress --ignore-existing docker-compose.yml -e ssh "$host":docker if [[ $1 = "amd64" ]]; then platform="linux/amd64" @@ -65,12 +68,9 @@ function sync_test { platform="linux/amd64" fi - ssh "$host" "docker buildx build --platform $platform -t bbilly1/tubearchivist:latest tubearchivist --load" + ssh "$host" "docker buildx build --build-arg INSTALL_DEBUG=1 --platform $platform -t bbilly1/tubearchivist:latest tubearchivist --load" ssh "$host" 'docker-compose -f docker/docker-compose.yml up -d' - ssh "$host" 'docker cp tubearchivist/tubearchivist/testing.sh tubearchivist:/app/testing.sh' - ssh "$host" 'docker exec tubearchivist chmod +x /app/testing.sh' - } diff --git a/tubearchivist/testing.sh b/tubearchivist/testing.sh deleted file mode 100644 index ae20ba1..0000000 --- a/tubearchivist/testing.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -# install debug and testing tools into slim container - -apt update && apt install -y vim htop bmon net-tools iputils-ping procps - -pip install ipython - -## -exit 0