cherry_be/.gitlab-ci.yml.bak
2022-02-02 11:36:28 +00:00

55 lines
926 B
YAML

variables:
APP_NAME: "cherry_be"
OUTSIDE_PORT: 5018
INSIDE_PORT: 7980
IMAGE_NAME: "$APP_NAME:$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA"
DOCKER_FILE_PATH: "./Dockerfile"
stages:
- build
- clear
- deploy
- rmimg
build:
stage: build
image: docker:latest
services:
- name: docker:dind
tags:
- dockerbase
script:
- ls -a
- docker build -t ${IMAGE_NAME} -f ${DOCKER_FILE_PATH} .
clear:
stage: clear
tags:
- dockerbase
only:
- master
script:
- docker stop ${APP_NAME}
- docker rm ${APP_NAME}
allow_failure: true
deploy:
stage: deploy
tags:
- dockerbase
only:
- master
script:
- ls -a
- docker run -t -d --name ${APP_NAME} -p ${OUTSIDE_PORT}:${INSIDE_PORT} ${IMAGE_NAME}
rmimg:
stage: rmimg
tags:
- dockerbase
only:
- master
script:
- docker image rm `docker image ls -q ${APP_NAME} | tail -1`
allow_failure: true