Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pado
Asyst Moodle Plugin
Commits
df6dd85b
Commit
df6dd85b
authored
3 months ago
by
Artem Baranovskyi
Browse files
Options
Download
Email Patches
Plain Diff
Image build is optimized.
parent
38ed74fc
Pipeline
#10887
failed with stages
in 2 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.gitlab-ci.yml
+23
-15
.gitlab-ci.yml
flask_ml_api/Dockerfile
+16
-17
flask_ml_api/Dockerfile
with
39 additions
and
32 deletions
+39
-32
.gitlab-ci.yml
+
23
-
15
View file @
df6dd85b
...
@@ -23,30 +23,38 @@ variables:
...
@@ -23,30 +23,38 @@ variables:
DOCKER_CPUS
:
"
2"
DOCKER_CPUS
:
"
2"
DOCKER_REGISTRY
:
docker.io
DOCKER_REGISTRY
:
docker.io
before_script
:
-
mkdir -p ~/.docker
-
echo $DOCKER_CONFIG_JSON | base64 -d > ~/.docker/config.json
-
docker system prune -a -f --volumes ||
true
-
apt-get update && apt-get install -y apt-utils && apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/*
build
:
build
:
stage
:
build
stage
:
build
image
:
docker:
20.10.16
image
:
docker:
dind
services
:
services
:
-
name
:
docker:20.10.16-dind
-
name
:
docker:dind
command
:
[
"
--host=tcp://docker:2375"
,
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
command
:
[
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
before_script
:
-
mkdir -p ~/.docker
-
echo $DOCKER_CONFIG_JSON | base64 -d > ~/.docker/config.json
-
mkdir -p /mnt/volume
-
mount /dev/vdb /mnt/volume || echo "Failed to mount /dev/vdb"
-
export DOCKER_TMPDIR=/mnt/volume
-
docker system prune -a -f --volumes ||
true
-
df -h
after_script
:
-
docker system prune -a -f
-
docker volume prune -f
script
:
script
:
-
docker buildx create --use
-
docker build --cache-from=asyst-nlp-grader --no-cache --progress=plain -t asyst-nlp-grader -f flask_ml_api/Dockerfile .
-
docker buildx build --cache-from=type=registry,ref=22baar1mst/asyst-nlp-grader --no-cache --progress=plain -t 22baar1mst/asyst-nlp-grader:latest -f flask_ml_api/Dockerfile .
-
docker push 22baar1mst/asyst-nlp-grader:latest
-
docker push 22baar1mst/asyst-nlp-grader:latest
only
:
cache
:
-
master
key
:
build-cache
paths
:
-
/mnt/volume
timeout
:
1h
deploy
:
deploy
:
stage
:
deploy
stage
:
deploy
image
:
docker:20.10.16
dependencies
:
-
build
services
:
services
:
-
name
:
docker:
20.10.16-
dind
-
name
:
docker:dind
command
:
[
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
command
:
[
"
--tls=false"
,
"
--storage-driver=overlay2"
,
"
--mtu=1500"
,
"
--data-root=/mnt/volume"
]
script
:
script
:
-
docker pull 22baar1mst/asyst-nlp-grader:latest
-
docker pull 22baar1mst/asyst-nlp-grader:latest
...
...
This diff is collapsed.
Click to expand it.
flask_ml_api/Dockerfile
+
16
-
17
View file @
df6dd85b
FROM
debian:bullseye-slim
as
base
FROM
pytorch/pytorch:2.0.1-cuda11.7-cudnn8-runtime
AS
builder
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
build-essential python3-venv
curl
&&
\
build-essential python3-venv
&&
\
apt-get clean
&&
\
apt-get clean
&&
\
rm
-rf
/var/lib/apt/lists/
*
/tmp/
*
/var/tmp/
*
/usr/share/doc /usr/share/man /usr/share/locale
rm
-rf
/var/lib/apt/lists/
*
RUN
python3
-m
venv /opt/myenv
RUN
python3
-m
venv /opt/myenv
ENV
PATH="/opt/myenv/bin:$PATH"
ENV
PATH="/opt/myenv/bin:$PATH"
RUN
pip
install
--no-cache-dir
Flask
&&
\
WORKDIR
/app
pip
install
--no-cache-dir
pytorch
&&
\
COPY
. /app
pip
install
--no-cache-dir
matplotlib
&&
\
pip
install
--no-cache-dir
scikit-learn
&&
\
pip
install
--no-cache-dir
transformers
&&
\
pip
install
--no-cache-dir
pandas
&&
\
pip
install
--no-cache-dir
sentence_transformers
&&
\
pip
install
--no-cache-dir
--upgrade
setuptools wheel
\
rm
-rf
/root/.cache/pip
# Install dependencies in smaller steps
RUN
pip
install
--no-cache-dir
Flask matplotlib scikit-learn transformers pandas sentence_transformers
RUN
pip
install
--no-cache-dir
--upgrade
setuptools wheel
FROM
base
as
build
# Final image
COPY
--from=build /opt/myenv /opt/myenv
FROM
python:3.10-slim
WORKDIR
/app
COPY
--from=builder /opt/myenv /opt/myenv
COPY
. /app
COPY
--from=builder /app /app
ENV
PATH="/opt/myenv/bin:$PATH"
RUN
chown
-R
www-data:www-data /app
&&
chmod
-R
755 /app
RUN
chown
-R
www-data:www-data /app
&&
chmod
-R
755 /app
EXPOSE
5000
EXPOSE
5000
CMD
["/opt/myenv/bin/python", "/app/api.py"]
\ No newline at end of file
CMD
["/opt/myenv/bin/python", "/app/api.py"]
This diff is collapsed.
Click to expand it.
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