diff --git a/.gitignore b/.gitignore index abee4873414bb250d76fc922c41c2fa969a838e6..5bb5b23cce190022bb2a45d954e5dc1920aa6605 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.idea/ /venv/ data +__pycache__ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fa59dd27f480ba5ddf64cb5d7995eadc4b67c194..799d78829472462b920433a26b3563558fcc9f19 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,4 +1,4 @@ -image: registry.kszk.bme.hu/baseimg/python-tools +image: python:3.8.5-buster stages: - Get dependencies @@ -6,32 +6,60 @@ stages: - Docker build variables: + # git tag or branch name CONTAINER_IMAGE: "registry.kszk.bme.hu/monitoring/pupak:$CI_COMMIT_REF_NAME" pip: stage: Get dependencies script: - - python --version - pip install -r requirements.txt flake8: stage: Static Analysis script: + - pip install flake8 - flake8 --max-line-length=120 *.py pylint: stage: Static Analysis allow_failure: true script: + - pip install pylint - pylint -d C0301 *.py -docker build: +docker kszk: + extends: .image-template + variables: + REGISTRY: registry.kszk.bme.hu + REGISTRY_USER: "$KSZK_NEXUS_USERNAME" + REGISTRY_PASSWORD: "$KSZK_NEXUS_PASSWORD" + IMAGE: registry.kszk.bme.hu/monitoring/pupak:$CI_COMMIT_REF_NAME + +docker hub: + extends: .image-template + variables: + REGISTRY: "https://index.docker.io/v1/" + REGISTRY_USER: "$HUB_USER" + REGISTRY_PASSWORD: "$HUB_PASS" + IMAGE: robotka/pupak:$CI_COMMIT_REF_NAME + +###################### Docker image build template ####################### + +# hidden job, not gonna run, just for the inheritance +.image-template: stage: Docker build image: name: gcr.io/kaniko-project/executor:debug entrypoint: [""] script: - - echo "{\"auths\":{\"registry.kszk.bme.hu\":{\"username\":\"$KSZK_NEXUS_USERNAME\",\"password\":\"$KSZK_NEXUS_PASSWORD\"}}}" > /kaniko/.docker/config.json - - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile --destination "$CONTAINER_IMAGE" + - echo "{\"auths\":{\"$REGISTRY\":{\"username\":\"$REGISTRY_USER\",\"password\":\"$REGISTRY_PASSWORD\"}}}" + > /kaniko/.docker/config.json + - echo "Push $IMAGE to $REGISTRY" + - /kaniko/executor + --context $CI_PROJECT_DIR + --dockerfile $CI_PROJECT_DIR/Dockerfile + --destination "$IMAGE" only: - master + - tags +