emoji-flask-app/.gitlab-ci.yml

36 lines
1.5 KiB
YAML
Raw Normal View History

2022-06-20 04:15:59 +00:00
# .gitlab-ci.yml
2023-08-25 22:48:59 +00:00
stages:
- dockerize
- deployment
2022-06-20 04:15:59 +00:00
build-push-docker-image-job:
2023-08-25 22:48:59 +00:00
stage: dockerize
2022-06-20 04:15:59 +00:00
# Specify a Docker image to run the job in.
2022-07-09 16:30:51 +00:00
image: docker:20-dind
2022-06-20 04:15:59 +00:00
# Specify an additional image 'docker:dind' ("Docker-in-Docker") that
# will start up the Docker daemon when it is brought up by a runner.
2023-08-25 22:48:59 +00:00
before_script:
- docker login -u "$DOCKER_REGISTRY_USER" -p "$DOCKER_REGISTRY_PASSWORD" $DOCKER_REGISTRY_URL # Instructs GitLab to login to its registry
2022-06-20 04:15:59 +00:00
services:
2022-07-09 16:30:51 +00:00
- name: docker:20-dind
alias: docker
command: ["--tls=false"]
2022-06-20 04:15:59 +00:00
script:
2023-08-25 22:48:59 +00:00
- echo "Building..." # MAKE SURE NO SPACE ON EITHER SIDE OF = IN THE FOLLOWING LINE
- export CONTAINER_FULL_IMAGE_NAME_WITH_TAG=$IMAGE_NAME_WITH_REGISTRY_PREFIX/my-build-image:$COMMIT_HASH
- docker build -f ./Dockerfile --pull -t built-image-name .
- docker tag built-image-name "$CONTAINER_FULL_IMAGE_NAME_WITH_TAG"
- docker push "$CONTAINER_FULL_IMAGE_NAME_WITH_TAG"
- echo $CONTAINER_FULL_IMAGE_NAME_WITH_TAG
- echo "Deploying on CapRover..."
- docker run caprover/cli-caprover:v2.1.1 caprover deploy --caproverUrl $CAPROVER_URL --caproverPassword $CAPROVER_PASSWORD --caproverApp $CAPROVER_APP --imageName $CONTAINER_FULL_IMAGE_NAME_WITH_TAG
only:
- main
2022-07-09 16:30:51 +00:00
variables:
2023-08-25 22:48:59 +00:00
DOCKER_REGISTRY_USER: ${CI_REGISTRY_USER}
DOCKER_REGISTRY_PASSWORD: ${CI_REGISTRY_PASSWORD}
DOCKER_REGISTRY_URL: ${CI_REGISTRY}
IMAGE_NAME_WITH_REGISTRY_PREFIX: ${CI_REGISTRY_IMAGE}
COMMIT_HASH: ${CI_COMMIT_SHA}