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
8d3941a6
Commit
8d3941a6
authored
Dec 31, 2024
by
Artem Baranovskyi
Browse files
Image build is optimized.
parent
875b282c
Pipeline
#10607
failed with stage
in 52 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
flask_ml_api/Dockerfile
View file @
8d3941a6
# Build stage
# Build stage
FROM
python:3.10-
alpine
AS
builder
FROM
python:3.10-
slim
AS
builder
# Install system dependencies
# Install system dependencies
RUN
apk add
--no-cache
\
RUN
apk add
--no-cache
\
...
@@ -15,8 +15,7 @@ WORKDIR /app
...
@@ -15,8 +15,7 @@ WORKDIR /app
COPY
. /app
COPY
. /app
# Install dependencies in separate steps to reduce memory usage
# Install dependencies in separate steps to reduce memory usage
RUN
apk add
--no-cache
gcompat
RUN
/opt/myenv/bin/pip
install
torch
&&
\
RUN
/opt/myenv/bin/pip
install
torch
--index-url
https://download.pytorch.org/whl/cpu
&&
\
rm
-rf
/root/.cache/pip
\
rm
-rf
/root/.cache/pip
\
RUN /opt/myenv/bin/pip
install
Flask
&&
\
RUN /opt/myenv/bin/pip
install
Flask
&&
\
rm
-rf
/root/.cache/pip
rm
-rf
/root/.cache/pip
...
@@ -33,10 +32,11 @@ RUN /opt/myenv/bin/pip install sentence_transformers && \
...
@@ -33,10 +32,11 @@ RUN /opt/myenv/bin/pip install sentence_transformers && \
RUN
/opt/myenv/bin/pip
install
--upgrade
setuptools wheel
RUN
/opt/myenv/bin/pip
install
--upgrade
setuptools wheel
# Final image
# Final image
FROM
python:3.10-
alpine
FROM
python:3.10-
slim
# Install system dependencies
# Install system dependencies
RUN
apk add
--no-cache
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 virtual environment and application from build stage
COPY
--from=builder /opt/myenv /opt/myenv
COPY
--from=builder /opt/myenv /opt/myenv
...
...
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