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
fbc1814f
Commit
fbc1814f
authored
Jan 04, 2025
by
Artem Baranovskyi
Browse files
Image build is optimized.
parent
b1615fb1
Pipeline
#10684
failed with stages
in 12 minutes and 41 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
fbc1814f
...
@@ -19,6 +19,8 @@ variables:
...
@@ -19,6 +19,8 @@ variables:
DOCKER_TLS_CERTDIR
:
"
"
DOCKER_TLS_CERTDIR
:
"
"
DOCKER_HOST
:
"
unix:///var/run/docker.sock"
DOCKER_HOST
:
"
unix:///var/run/docker.sock"
DOCKER_OPTS
:
"
--data-root=/mnt/volume/docker-data"
DOCKER_OPTS
:
"
--data-root=/mnt/volume/docker-data"
DOCKER_MEMORY
:
"
4g"
DOCKER_CPUS
:
"
2"
build
:
build
:
stage
:
build
stage
:
build
...
...
flask_ml_api/Dockerfile
View file @
fbc1814f
# Build stage
# Build stage
FROM
pyt
hon:3.10-sl
im
AS
builder
FROM
pyt
orch/pytorch:2.0.1-cuda11.7-cudnn8-runt
im
e
AS
builder
# Install system dependencies
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
build-essential
\
build-essential python3-venv
&&
\
python3-venv
\
apt-get clean
&&
\
&&
apt-get clean
\
rm
-rf
/var/lib/apt/lists/
*
&&
rm
-rf
/var/lib/apt/lists/
*
# Create and activate virtual environment
RUN
python3
-m
venv /opt/myenv
RUN
python3
-m
venv /opt/myenv
ENV
PATH="/opt/myenv/bin:$PATH"
ENV
PATH="/opt/myenv/bin:$PATH"
WORKDIR
/app
WORKDIR
/app
COPY
. /app
COPY
. /app
# Install dependencies in separate steps to reduce memory usage
# Install dependencies in smaller steps
RUN
/opt/myenv/bin/pip
install
torch
&&
\
RUN
pip
install
--no-cache-dir
Flask matplotlib scikit-learn transformers pandas sentence_transformers
rm
-rf
/root/.cache/pip
\
RUN
pip
install
--no-cache-dir
--upgrade
setuptools wheel
RUN /opt/myenv/bin/pip
install
Flask
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
matplotlib
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
scikit-learn
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
transformers
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
pandas
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
sentence_transformers
&&
\
rm
-rf
/root/.cache/pip
RUN
/opt/myenv/bin/pip
install
--upgrade
setuptools wheel
# Final image
# Final image
FROM
python:3.10-slim
FROM
python:3.10-slim
# Install system dependencies
RUN
apt-get update
&&
apt-get
install
-y
--no-install-recommends
\
&&
rm
-rf
/var/lib/apt/lists/
*
# Copy virtual environment and application from build stage
COPY
--from=builder /opt/myenv /opt/myenv
COPY
--from=builder /opt/myenv /opt/myenv
COPY
--from=builder /app /app
COPY
--from=builder /app /app
# Activate virtual environment in the final image
ENV
PATH="/opt/myenv/bin:$PATH"
ENV
PATH="/opt/myenv/bin:$PATH"
# Set permissions
RUN
chown
-R
www-data:www-data /app
&&
chmod
-R
755 /app
RUN
chown
-R
www-data:www-data /app/asyst
\
&&
chmod
-R
755 /app/asyst
# Expose port for Flask API
EXPOSE
5000
EXPOSE
5000
# Run the application
CMD
["/opt/myenv/bin/python", "/app/api.py"]
CMD
["/opt/myenv/bin/python", "/app/api.py"]
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