From f220d7318b11e0837736a2d1a824bb45e8b2d103 Mon Sep 17 00:00:00 2001 From: Anton Smorodskyi Date: Fri, 2 Feb 2024 15:40:42 +0100 Subject: [PATCH] Create dedicated folder for containers and add base image --- .dockerignore | 4 ++++ .github/workflows/container.yml | 6 +++--- .github/workflows/lint.yml | 8 ++++---- Makefile | 14 +++++++------- Dockerfile => containers/Dockerfile | 7 ++----- Dockerfile_dev => containers/Dockerfile_dev | 0 Dockerfile_k8s => containers/Dockerfile_k8s | 0 .../Dockerfile_k8s_dev | 0 container-startup => containers/container-startup | 0 9 files changed, 20 insertions(+), 19 deletions(-) rename Dockerfile => containers/Dockerfile (94%) rename Dockerfile_dev => containers/Dockerfile_dev (100%) rename Dockerfile_k8s => containers/Dockerfile_k8s (100%) rename Dockerfile_k8s_dev => containers/Dockerfile_k8s_dev (100%) rename container-startup => containers/container-startup (100%) diff --git a/.dockerignore b/.dockerignore index f2f3a83c..c6cdb049 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,7 +1,11 @@ # Ignore git, data and cache files .git +.github .cache +.pytest_cache + __pycache__ /db +/tests # Also ignore templates /templates diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 57d26252..98e2dcde 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -94,7 +94,7 @@ jobs: uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 with: context: . - file: Dockerfile + file: containers/Dockerfile push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} @@ -103,7 +103,7 @@ jobs: uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 with: context: . - file: Dockerfile_${{ matrix.suffix }} + file: containers/Dockerfile_${{ matrix.suffix }} push: true tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9dafc912..f5ed6231 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -41,13 +41,13 @@ jobs: - uses: actions/checkout@v4 - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: 'Dockerfile' + dockerfile: 'containers/Dockerfile' - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: 'Dockerfile_dev' + dockerfile: 'containers/Dockerfile_dev' - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: 'Dockerfile_k8s' + dockerfile: 'containers/Dockerfile_k8s' - uses: hadolint/hadolint-action@v3.1.0 with: - dockerfile: 'Dockerfile_k8s_dev' + dockerfile: 'containers/Dockerfile_k8s_dev' diff --git a/Makefile b/Makefile index 1adb23d0..b17fbece 100644 --- a/Makefile +++ b/Makefile @@ -28,17 +28,17 @@ codecov: # Build containers docker-container: - docker build . -t ${CONT_TAG} + docker build . -t ${CONT_TAG} -f containers/Dockerfile podman-container: - podman build . -t ${CONT_TAG} + podman build . -t ${CONT_TAG} -f containers/Dockerfile podman-container-devel: - podman build -f Dockerfile_dev -t pcw-devel + podman build . -f containers/Dockerfile_dev -t pcw-devel podman-container-k8s: - podman build -f Dockerfile_k8s -t pcw-k8s-cleaner + podman build . -f containers/Dockerfile_k8s -t pcw-k8s-cleaner podman-container-k8s-devel: - podman build -f Dockerfile_k8s_dev -t pcw-k8s-cleaner-devel + podman build . -f containers/Dockerfile_k8s_dev -t pcw-k8s-cleaner-devel # Container linting .PHONY: container-lint -container-lint: Dockerfile* - hadolint Dockerfile* +container-lint: containers/Dockerfile* + hadolint containers/Dockerfile* diff --git a/Dockerfile b/containers/Dockerfile similarity index 94% rename from Dockerfile rename to containers/Dockerfile index e7dda81f..ef68da85 100644 --- a/Dockerfile +++ b/containers/Dockerfile @@ -1,10 +1,5 @@ FROM registry.suse.com/bci/python:3.11 -ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 UWSGI_WSGI_FILE=/pcw/webui/wsgi.py UWSGI_MASTER=1 -ENV UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy - -## System preparation steps ################################################# ## - # We do the whole installation and configuration in one layer: COPY requirements.txt /pcw/ # * Install system requirements @@ -32,6 +27,8 @@ EXPOSE 8000/tcp # Required to use system certs in python-requests ENV REQUESTS_CA_BUNDLE=/etc/ssl/ca-bundle.pem +ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1 UWSGI_WSGI_FILE=/pcw/webui/wsgi.py UWSGI_MASTER=1 +ENV UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy # Once we are certain that this runs nicely, replace this with ENTRYPOINT. ENTRYPOINT ["/pcw/container-startup", "run"] diff --git a/Dockerfile_dev b/containers/Dockerfile_dev similarity index 100% rename from Dockerfile_dev rename to containers/Dockerfile_dev diff --git a/Dockerfile_k8s b/containers/Dockerfile_k8s similarity index 100% rename from Dockerfile_k8s rename to containers/Dockerfile_k8s diff --git a/Dockerfile_k8s_dev b/containers/Dockerfile_k8s_dev similarity index 100% rename from Dockerfile_k8s_dev rename to containers/Dockerfile_k8s_dev diff --git a/container-startup b/containers/container-startup similarity index 100% rename from container-startup rename to containers/container-startup