Skip to content

Commit

Permalink
feat(CICD): add docker linter
Browse files Browse the repository at this point in the history
  • Loading branch information
panpuchkov committed Dec 23, 2023
1 parent 8ec595c commit 4cd8767
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ permissions: write-all
- main
env:
IMAGE_NAME: 'pygitver'
REGISTRY_NAME: pygitver
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}

jobs:
unittests:
Expand All @@ -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}"
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 4cd8767

Please sign in to comment.