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
6b5ec678
Commit
6b5ec678
authored
Dec 15, 2024
by
Artem Baranovskyi
Browse files
Image build is optimized.
parent
557ae891
Changes
1
Hide whitespace changes
Inline
Side-by-side
flask_ml_api/Dockerfile
View file @
6b5ec678
FROM
python:3.11-slim
# Build stage
FROM
python:3.10-slim
AS
builder
# Install
ing
system dependencies
# 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
\
curl
\
&&
rm
-rf
/var/lib/apt/lists/
*
&&
rm
-rf
/var/lib/apt/lists/
*
# Creat
ing
and activat
ing th
e virtual environment
\
# Creat
e
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
COPY
./asyst /app/asyst
COPY
./asyst /app/asyst
COPY
requirements.txt .
# Install
ing
dependencies
# Install dependencies
RUN
/opt/myenv/bin/pip
install
-r
/app/requirements.txt
RUN
/opt/myenv/bin/pip
install
-r
/app/requirements.txt
\
RUN
/opt/myenv/bin/python3
-m
pip
install
--upgrade
setuptools wheel
&&
/opt/myenv/bin/python3
-m
pip
install
--upgrade
setuptools wheel
# Final image
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 /app /app
# Activate virtual environment in the final image
ENV
PATH="/opt/myenv/bin:$PATH"
# Set permissions
# Set permissions
RUN
chown
-R
www-data:www-data /app/asyst
RUN
chown
-R
www-data:www-data /app/asyst
\
RUN
chmod
-R
755 /app/asyst
&&
chmod
-R
755 /app/asyst
#
Open
port for Flask API
#
Expose
port for Flask API
EXPOSE
5000
EXPOSE
5000
# Launch application
# Run the application
CMD
["python", "/app/api.py"]
CMD
["/opt/myenv/bin/python", "/app/api.py"]
\ No newline at end of file
\ 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