stages:
    - build
    - deploy
    
variables:    
    IMAGE_NAME: 192.168.0.201:5000/web_company_site
    CONTAINER_NAME: web_company_site

build_push_image:
    stage: build
    script:
        - docker build -t $IMAGE_NAME .
    after_script:
        - docker push $IMAGE_NAME
    tags:
        - docker-run
        
remote_run_image:
    stage: deploy
    before_script:
        - docker stop $CONTAINER_NAME || true && docker rm $CONTAINER_NAME || true docker rmi $IMAGE_NAME
    script:
        - docker pull $IMAGE_NAME
    after_script:
        - docker run -d --name $CONTAINER_NAME -p 8066:80 --restart always $IMAGE_NAME
    tags:
        - ssh

