From 3b9a9636f52b2d8d95abde383b921de0449b9520 Mon Sep 17 00:00:00 2001 From: Robert McMahan Date: Fri, 5 Jan 2024 21:39:43 +0000 Subject: [PATCH 1/5] Adds Docker BuildKit and CHMOD so this is handled automatically. --- postgres.Dockerfile | 2 +- run_tightlock.sh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/postgres.Dockerfile b/postgres.Dockerfile index 5c69fc74..7f57ed17 100644 --- a/postgres.Dockerfile +++ b/postgres.Dockerfile @@ -13,4 +13,4 @@ # limitations under the License. FROM postgres:15 -COPY postgres_init.sh /docker-entrypoint-initdb.d/ +COPY --chmod=755 postgres_init.sh /docker-entrypoint-initdb.d/ diff --git a/run_tightlock.sh b/run_tightlock.sh index 75be7174..1aeea337 100755 --- a/run_tightlock.sh +++ b/run_tightlock.sh @@ -25,9 +25,12 @@ esac done -# Create env +# create env bash ./create_env.sh $INTERACTIVE_FLAG $ENV_FLAG $PROVIDED_API_KEY +# enable docker buildkit +export DOCKER_BUILDKIT=1 + # define which docker-compose command to use based on the environment if [ $ENV_FLAG == "prod" ]; then COMPOSE_CMD="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm -v $PWD:$PWD -w $PWD docker/compose:1.29.2" @@ -35,5 +38,5 @@ else COMPOSE_CMD='docker-compose' fi -# Run containers +# run containers $COMPOSE_CMD up --build -d From 36a9517ab704a386f01c55cb1cfdc0b934b1b391 Mon Sep 17 00:00:00 2001 From: Robert McMahan Date: Fri, 5 Jan 2024 21:55:38 +0000 Subject: [PATCH 2/5] Adding docker buildkit to integration_tests. --- run_integration_tests.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/run_integration_tests.sh b/run_integration_tests.sh index 8ffe761e..3124358e 100755 --- a/run_integration_tests.sh +++ b/run_integration_tests.sh @@ -15,7 +15,7 @@ # update pip version python3 -m pip install --user --upgrade pip setuptools wheel -# Create test venv +# create test venv ENV_NAME=".tightlock_integration_test_venv" python3 -m venv $ENV_NAME @@ -24,11 +24,14 @@ PY3=$ENV_NAME/bin/python $PY3 -m pip install -r integration_tests/test_requirements.txt -# Create env -./create_env.sh non-interactive test +# create env +./create_env.sh non-interactive test -# Remove potentially running containers and run integration tests -docker-compose down +# enable docker buildkit +export DOCKER_BUILDKIT=1 + +# remove potentially running containers and run integration tests +docker-compose down $PY3 -m pytest -s --no-header -vv --docker-compose=docker-compose.yaml integration_tests/ # get return value of integration tests run From 8846bc10d4aec0ca98a5008a65f681306ec3377d Mon Sep 17 00:00:00 2001 From: Robert McMahan Date: Tue, 16 Jan 2024 20:04:31 +0000 Subject: [PATCH 3/5] Adds docker buildkit to github action. --- .github/workflows/main.yml | 4 ++++ run_integration_tests.sh | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 55754776..9b7eb5ee 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,10 @@ on: workflow_dispatch: push: { branches: [main]} +env: + DOCKER_BUILDKIT: 1 + COMPOSE_DOCKER_CLI_BUILD: 1 + jobs: unit-tests: runs-on: ubuntu-latest diff --git a/run_integration_tests.sh b/run_integration_tests.sh index 3124358e..0c0e7ea0 100755 --- a/run_integration_tests.sh +++ b/run_integration_tests.sh @@ -27,11 +27,8 @@ $PY3 -m pip install -r integration_tests/test_requirements.txt # create env ./create_env.sh non-interactive test -# enable docker buildkit -export DOCKER_BUILDKIT=1 - # remove potentially running containers and run integration tests -docker-compose down +docker-compose down -v $PY3 -m pytest -s --no-header -vv --docker-compose=docker-compose.yaml integration_tests/ # get return value of integration tests run From 0e5cea864c3ed27fbaa61b85e8cacc3d204ab780 Mon Sep 17 00:00:00 2001 From: Robert McMahan Date: Tue, 16 Jan 2024 20:10:45 +0000 Subject: [PATCH 4/5] Takes a different approach. --- .github/workflows/main.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9b7eb5ee..22eac715 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,10 +3,6 @@ on: workflow_dispatch: push: { branches: [main]} -env: - DOCKER_BUILDKIT: 1 - COMPOSE_DOCKER_CLI_BUILD: 1 - jobs: unit-tests: runs-on: ubuntu-latest @@ -36,6 +32,8 @@ jobs: - uses: actions/checkout@v3 - name: Run Integration Tests run: bash ./run_integration_tests.sh + env: + DOCKER_BUILDKIT: 1 - name: Rename logs run: for i in logs/**/*:*:*; do mv -- "$i" "${i//:/_}"; done - name: Archive logs From 963c5423a9d1d0e3b513b2839dcb9efaee07cdf7 Mon Sep 17 00:00:00 2001 From: Robert McMahan Date: Tue, 16 Jan 2024 20:23:03 +0000 Subject: [PATCH 5/5] Latest docker has buildkit by default. Trying to update prior to run to see if this works. --- .github/workflows/main.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 22eac715..48ce3315 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,10 +30,14 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + - name: Install Latest Docker + run: | + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" + sudo apt-get update + sudo apt-get install docker-ce - name: Run Integration Tests run: bash ./run_integration_tests.sh - env: - DOCKER_BUILDKIT: 1 - name: Rename logs run: for i in logs/**/*:*:*; do mv -- "$i" "${i//:/_}"; done - name: Archive logs