From 4cd8767d61fb390cb36fe91d487c9f85e5b2af21 Mon Sep 17 00:00:00 2001 From: Yurii Puchkov Date: Sat, 23 Dec 2023 16:48:03 -0700 Subject: [PATCH] feat(CICD): add docker linter --- .github/workflows/build.yaml | 18 +++++++++++++----- Dockerfile | 4 ++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index dc94628..a795b09 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,7 +13,7 @@ permissions: write-all - main env: IMAGE_NAME: 'pygitver' - REGISTRY_NAME: pygitver + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} jobs: unittests: @@ -33,25 +33,33 @@ jobs: build: runs-on: ubuntu-latest needs: unittests - if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v3 + - name: Dockerfile lint + if: ${{ env.IMAGE_EXIST == 'false' }} + id: validate-dockerfile + shell: bash + run: | + docker run --rm -e HADOLINT_IGNORE=DL3007,DL3008,DL3018,DL4006,DL3013 -i hadolint/hadolint < Dockerfile + - name: Docker Build shell: bash run: | set -x - docker build -t "panpuchkov/${{ env.IMAGE_NAME }}" . + docker build -t "${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}" . - name: Log in to Docker Hub + if: github.ref == 'refs/heads/main' uses: docker/login-action@v3 with: - username: panpuchkov + username: ${{ env.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Docker Push + if: github.ref == 'refs/heads/main' shell: bash run: | set -x - IMAGE_NAME_WITH_VERSION="panpuchkov/${{ env.IMAGE_NAME }}:latest" + IMAGE_NAME_WITH_VERSION="${{ env.DOCKER_USERNAME }}/${{ env.IMAGE_NAME }}:latest" docker push "${IMAGE_NAME_WITH_VERSION}" diff --git a/Dockerfile b/Dockerfile index 6d6d43d..76f080c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,8 +10,8 @@ ENV PATH="/opt/venv/bin:$PATH" # Install pip requirements COPY ./requirements.txt /pygitver/requirements.txt -RUN pip install -U pip \ - && pip install -r /pygitver/requirements.txt --no-cache-dir +RUN pip install --no-cache-dir -U pip \ + && pip install --no-cache-dir -r /pygitver/requirements.txt FROM python:3.12-alpine