From ff0880ccc733c3a1b4e0222c6bc4c2d67f59ae6c Mon Sep 17 00:00:00 2001 From: Michael Tauraso Date: Tue, 5 Nov 2024 12:22:47 -0800 Subject: [PATCH] Initial docker compose build github action --- .github/workflows/docker-build.yml | 68 ++++++++++++++++++++++++++++++ tom_desc/fastdb_dev/DataTools.py | 4 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-build.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 00000000..274495c6 --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,68 @@ +name: Build Docker image +# Shamelessly cribbed from https://docs.docker.com/build/ci/github-actions/test-before-push/ +# with minor modifications +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + TEST_TAG: user/app:test + LATEST_TAG: user/app:latest + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Run docker-compose + uses: hoverkraft-tech/compose-action@v2.0.1 + with: + compose-file: "./docker-compose.yml" + services: "tom" + up-flags: "--remove-orphans" + + - name: Test + run: docker run --network tom_desc_default appropriate/curl -s --retry 10 --retry-connrefused http://tom:8080/ + +# test2: +# runs-on: ubuntu-latest +# strategy: +# fail-fast: false +# matrix: +# #container_dir: [ docker_kafka, docker_postgres, docker_server] +# container_dir: [ docker_kafka] +# steps: +# - uses: actions/checkout@v4 +# - name: Set up Docker Buildx +# id: buildx +# uses: docker/setup-buildx-action@master + +# - name: Cache Docker layers +# uses: actions/cache@v2 +# with: +# path: /tmp/.buildx-cache +# key: ${{ runner.os }}-buildx-${{matrix.container_dir}}-${{ github.sha }} +# restore-keys: | +# ${{ runner.os }}-buildx-${{matrix.container_dir}} + +# - name: Build and push images +# uses: docker/build-push-action@v2 +# with: +# push: false +# load: true +# builder: ${{ steps.buildx.outputs.name }} +# tags: repo/${{matrix.container_dir}}:latest +# file: ${{matrix.container_dir}}/Dockerfile +# context: . +# cache-from: type=local,src=/tmp/.buildx-cache +# cache-to: type=local,dest=/tmp/.buildx-cache + +# stack: +# needs: test2 +# runs-on: ubuntu-latest +# steps: +# - name: Build the stack +# run: COMPOSE_DOCKER_CLI_BUILD=1 docker-compose build \ No newline at end of file diff --git a/tom_desc/fastdb_dev/DataTools.py b/tom_desc/fastdb_dev/DataTools.py index 3db5ec3a..d9d7199b 100644 --- a/tom_desc/fastdb_dev/DataTools.py +++ b/tom_desc/fastdb_dev/DataTools.py @@ -48,7 +48,9 @@ from rest_framework.settings import api_settings _logger = logging.getLogger("fastdb_queries") -_logout = logging.FileHandler( pathlib.Path( os.getenv('LOGDIR'), "/logs" ) / "fastdb_queries.log" ) +_log_path = pathlib.Path( os.environ.get('LOGDIR',"."), "/logs" ) +_log_path.mkdir(parents=True, exist_ok=True) +_logout = logging.FileHandler( _log_path / "fastdb_queries.log" ) _logger.addHandler( _logout ) _formatter = logging.Formatter( f'[%(asctime)s - %(levelname)s] - %(message)s', datefmt='%Y-%m-%d %H:%M:%S' )