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
aae46967
Commit
aae46967
authored
Jan 05, 2025
by
Artem Baranovskyi
Browse files
Image build is optimized.
parent
08a4b388
Pipeline
#10719
failed
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
aae46967
...
@@ -12,49 +12,58 @@
...
@@ -12,49 +12,58 @@
stages
:
stages
:
-
build
-
build
-
containerize
-
deploy
-
deploy
variables
:
variables
:
DOCKER_DRIVER
:
overlay2
DOCKER_DRIVER
:
overlay2
DOCKER_TLS_CERTDIR
:
"
"
DOCKER_TLS_CERTDIR
:
"
"
DOCKER_HOST
:
"
unix:///var/run/docker.sock"
DOCKER_HOST
:
"
unix:///var/run/docker.sock"
# DOCKER_HOST: tcp://docker:2375/
DOCKER_OPTS
:
"
--data-root=/mnt/volume/docker-data"
DOCKER_OPTS
:
"
--data-root=/mnt/volume/docker-data"
DOCKER_MEMORY
:
"
4g"
DOCKER_MEMORY
:
"
4g"
DOCKER_CPUS
:
"
2"
DOCKER_CPUS
:
"
2"
before_script
:
build-job
:
-
mkdir -p ~/.docker
image
:
docker:latest
-
echo $DOCKER_CONFIG_JSON | base64 -d > ~/.docker/config.json
-
echo $DOCKER_PW | docker login -u $DOCKER_USER --password-stdin
-
docker system prune -a -f --volumes ||
true
-
docker container prune -f ||
true
-
docker network prune -f ||
true
-
docker image prune -a -f ||
true
-
docker builder prune -f ||
true
build
:
stage
:
build
stage
:
build
image
:
docker:dind
services
:
services
:
-
name
:
docker:dind
-
docker:dind
command
:
[
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
script
:
script
:
-
docker buildx create --use
-
echo "Building the Flask project"
# - docker buildx build --cache-from=type=registry,ref=$DOCKER_REPO --no-cache --progress=plain -t $DOCKER_REPO -f flask_ml_api/Dockerfile flask_ml_api
-
docker build -t $DOCKER_REPO:flask .
-
docker build --cache-from=flask-backend-full --no-cache --progress=plain -t flask-backend-full -f flask_ml_api/Dockerfile .
-
echo $DOCKER_REPO
-
docker push $DOCKER_REPO
only
:
-
master
deploy
:
containerize-job
:
image
:
docker:latest
stage
:
containerize
services
:
-
docker:dind
script
:
-
echo "Pushing Docker image to DockerHub"
-
docker login -u $DOCKER_USER -p $DOCKER_PW
-
docker push $DOCKER_REPO:flask
deploy-job
:
image
:
docker:latest
stage
:
deploy
stage
:
deploy
image
:
docker:dind
services
:
services
:
-
name
:
docker:dind
-
docker:dind
command
:
[
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
script
:
script
:
-
docker pull $DOCKER_REPO
-
echo "Deploying Flask container to BW_CLOUD"
-
docker run -d $DOCKER_REPO
-
apk add openssh-client
only
:
-
eval $(ssh-agent -s)
-
master
-
echo "$BW_CLOUD_SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
\ No newline at end of file
-
mkdir -p ~/.ssh
-
chmod 700 ~/.ssh
-
ssh -o StrictHostKeyChecking=no $BW_CLOUD_USER@$BW_CLOUD_IP "
set -x
sudo docker login -u $DOCKER_USER -p $DOCKER_PW
sudo docker stop flask-container ||
true
sudo docker rm flask-container ||
true
sudo docker pull $DOCKER_REPO:flask
sudo docker run --name flask-container -d -p 5000:5000 $DOCKER_REPO:flask
"
artifacts
:
paths
:
-
build/
\ No newline at end of file
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