Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
KNIGHT
Asyst Moodle Plugin
Commits
8ea3e499
Commit
8ea3e499
authored
Dec 10, 2024
by
Baranovskyi
Browse files
Update .gitlab-ci.yml file
parent
58c5c435
Pipeline
#10503
failed with stage
in 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
8ea3e499
...
@@ -22,7 +22,6 @@ stages:
...
@@ -22,7 +22,6 @@ stages:
variables
:
variables
:
DOCKER_HOST
:
tcp://docker:2375
DOCKER_HOST
:
tcp://docker:2375
DOCKER_DRIVER
:
overlay2
DOCKER_TLS_CERTDIR
:
"
"
DOCKER_TLS_CERTDIR
:
"
"
build-docker-image
:
build-docker-image
:
...
@@ -31,38 +30,29 @@ build-docker-image:
...
@@ -31,38 +30,29 @@ build-docker-image:
services
:
services
:
-
docker:dind
-
docker:dind
before_script
:
before_script
:
-
docker info
-
echo "$DOCKER_PW" | docker login -u "$DOCKER_USER" --password-stdin "$DOCKER_REPO"
-
docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
script
:
script
:
-
>
-
docker build -t "$DOCKER_REPO/$PROJECT:$CI_COMMIT_REF_SLUG" .
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
-
docker push "$DOCKER_REPO/$PROJECT:$CI_COMMIT_REF_SLUG"
tag="latest";
only
:
else
-
branches
tag="$CI_COMMIT_REF_SLUG";
fi
-
docker build --pull -t "$CI_REGISTRY_IMAGE:$tag" .
-
docker push "$CI_REGISTRY_IMAGE:$tag"
rules
:
-
exists
:
-
Dockerfile
deploy-to-bw-cloud
:
deploy-to-bw-cloud
:
image
:
alpine:latest
stage
:
deploy
stage
:
deploy
image
:
alpine:latest
before_script
:
before_script
:
-
apk add --no-cache sshpass
-
apk add --no-cache openssh-client
-
mkdir -p ~/.ssh
-
echo "$BW_CLOUD_SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
-
chmod 600 ~/.ssh/id_rsa
-
ssh-keyscan -H "$BW_CLOUD_IP" >> ~/.ssh/known_hosts
script
:
script
:
-
>
-
>
if [[ "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH" ]]; then
ssh "$BW_CLOUD_USER@$BW_CLOUD_IP" "
tag="latest";
docker pull $DOCKER_REPO/$PROJECT:$CI_COMMIT_REF_SLUG &&
else
docker stop flask-container || true &&
tag="$CI_COMMIT_REF_SLUG";
docker rm flask-container || true &&
fi
docker run -d --name flask-container -p 5001:5000 $DOCKER_REPO/$PROJECT:$CI_COMMIT_REF_SLUG
-
sshpass -p "$BW_CLOUD_PASSWORD" ssh -o StrictHostKeyChecking=no "$BW_CLOUD_USER@$BW_CLOUD_HOST" "
docker pull $CI_REGISTRY_IMAGE:$tag &&
docker stop flask-container ||
true
&&
docker rm flask-container ||
true
&&
docker run -d --name flask-container -p 5001:5000 $CI_REGISTRY_IMAGE:$tag
"
"
only
:
only
:
-
main
-
main
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment