Gitlab-CI =============================== ******************************************************************************** ## NodeJS .gitlab-ci.yml ******************************************************************************** image: node:latest before_script: - apt-get update - apt-get --yes --force-yes install ssh rsync cache: key: ${CI_COMMIT_REF_SLUG} paths: - my_modules/ stages: - build - production job_build: stage: build tags: - docker script: - npm install - npm run updateDependencies - cd ./my_modules/ - npm run build - pwd - ls job_production: stage: production tags: - docker when: on_success script: - pwd - ls - cp .htpasswd ./my_modules/dist/ - cd ./my_modules/ - ls dist - mkdir "${HOME}/.ssh" - echo "${SSH_KNOWN_HOSTS}" > "${HOME}/.ssh/known_hosts" - echo "${SSH_PRIVATE_KEY}" > "${HOME}/.ssh/id_rsa" - ls -al "${HOME}/.ssh/" - chmod 700 "${HOME}/.ssh/id_rsa" - rsync -hrvz --delete -e "ssh -p 2222 -i ${HOME}/.ssh/id_rsa" dist/ devops@172.20.1.10:/home/devops/www/js ******************************************************************************** ## Tensorflow and Python3 Dockerfile ******************************************************************************** FROM tensorflow/tensorflow:1.12.0-gpu MAINTAINER Farid Ahmadian RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive apt-get install -y \ python3-pip \ libsm6 \ libxext6 \ libxrender-dev \ && rm -r /var/lib/apt/lists/* RUN mkdir /app COPY setup.py /app RUN cd /app && \ python3 -m pip install --upgrade pip RUN cd /app && \ python3 -m pip install . RUN cd /app && \ python3 -m pip install .[testing] RUN cd /app && \ python3 -m pip install .[build_tools] # Goto temporary directory. WORKDIR /app ******************************************************************************** ## Tensorflow and Python3 .gitlab-ci.yml ******************************************************************************** stages: - build - test job_build: stage: build tags: - ssh script: # https://docs.gitlab.com/ce/user/project/container_registry.html#build-and-push-images - ls - nvidia-docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.pathseeker.ir - nvidia-docker build -t registry.pathseeker.ir/python-app:latest -f .docker/Dockerfile . - nvidia-docker push registry.pathseeker.ir/python-app:latest job_test: stage: test tags: - ssh script: - nvidia-docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.pathseeker.ir - nvidia-docker pull registry.pathseeker.ir/python-app:latest - nvidia-docker run -d --name "tensorflow-app" registry.pathseeker.ir/python-app:latest - nvidia-docker exec tensorflow-app ./test-runner.sh - nvidia-docker exec tensorflow-app ls -alt after_script: - nvidia-docker stop "tensorflow-app" - nvidia-docker rm "tensorflow-app" - nvidia-docker system prune -a -f ******************************************************************************** ## Tensorflow and Python3 test-runner.sh ******************************************************************************** #!/usr/bin/env bash pytest --junitxml=pytest_report.xml pylint src --rcfile=pylint.cfg || pylint-exit $? ******************************************************************************** _BY: Farid Ahmadian_ _TAG: nvidia, git, gitlab-CI, python, Dockerfile, docker_ _DATE: 2019-06-11 10:36:53_