Spaces:
Running
Running
alessandro trinca tornidor
commited on
Commit
•
767e8bd
1
Parent(s):
b57aef5
ci: update docker build process, update README.md
Browse files- Dockerfile +3 -67
- README.md +5 -2
- dockerfiles/dockerfile-base +72 -0
Dockerfile
CHANGED
@@ -1,50 +1,4 @@
|
|
1 |
-
|
2 |
-
ARG ARCH="x86_64"
|
3 |
-
ARG WORKDIR_ROOT="/var/task"
|
4 |
-
|
5 |
-
|
6 |
-
FROM python:3.12-bookworm AS builder_global
|
7 |
-
|
8 |
-
ARG ARCH
|
9 |
-
ARG WORKDIR_ROOT
|
10 |
-
ARG POETRY_NO_INTERACTION
|
11 |
-
ARG POETRY_VIRTUALENVS_IN_PROJECT
|
12 |
-
ARG POETRY_VIRTUALENVS_CREATE
|
13 |
-
ARG POETRY_CACHE_DIR
|
14 |
-
ARG ZLIB1G="http://ftp.it.debian.org/debian/pool/main/z/zlib/zlib1g_1.3.dfsg-3+b1_amd64.deb"
|
15 |
-
ENV PYTHONPATH="${WORKDIR_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
|
16 |
-
ENV MPLCONFIGDIR=/tmp/matplotlib
|
17 |
-
ARG USER="999"
|
18 |
-
|
19 |
-
|
20 |
-
RUN echo "ARCH: $ARCH, ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR}, ENV PYTHONPATH: $PYTHONPATH, USER: $USER ..."
|
21 |
-
# RUN groupadd -g 999 python && useradd -r -u 999 -g python python
|
22 |
-
|
23 |
-
# Set working directory to function root directory
|
24 |
-
WORKDIR ${WORKDIR_ROOT}
|
25 |
-
COPY --chown=python:python requirements.txt ${WORKDIR_ROOT}/
|
26 |
-
|
27 |
-
# avoid segment-geospatial exception caused by missing libGL.so.1 library
|
28 |
-
RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
29 |
-
RUN apt update && apt install -y curl ffmpeg libgl1 python3-pip && apt clean
|
30 |
-
COPY --chown=python:python ./dockerfiles/apt_preferences /etc/apt/preferences
|
31 |
-
COPY --chown=python:python ./dockerfiles/debian.sources /etc/apt/sources.list.d/debian.sources
|
32 |
-
RUN apt update && apt install -t trixie zlib1g -y && apt clean
|
33 |
-
RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
34 |
-
|
35 |
-
RUN ls -l /etc/apt/sources* /etc/apt/preferences*
|
36 |
-
|
37 |
-
# poetry installation path is NOT within ${WORKDIR_ROOT}: not needed for runtime docker image
|
38 |
-
RUN python3 -m venv ${WORKDIR_ROOT}/.venv
|
39 |
-
ENV PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
|
40 |
-
RUN . ${WORKDIR_ROOT}/.venv/bin/activate && python -m pip install -r ${WORKDIR_ROOT}/requirements.txt
|
41 |
-
|
42 |
-
# USER 999
|
43 |
-
|
44 |
-
|
45 |
-
FROM python:3.12-slim-bookworm AS runtime
|
46 |
-
|
47 |
-
RUN groupadd -g 999 python && useradd -r -u 999 -g python python
|
48 |
|
49 |
ARG ARCH
|
50 |
ARG WORKDIR_ROOT
|
@@ -54,24 +8,6 @@ ENV IS_DOCKER_CONTAINER="YES"
|
|
54 |
|
55 |
ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
|
56 |
|
57 |
-
RUN apt update && apt install -y ffmpeg && apt clean
|
58 |
-
RUN echo "COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
|
59 |
-
RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
60 |
-
RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
|
61 |
-
COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
|
62 |
-
COPY --chown=python:python --from=builder_global /lib/${ARCH}-linux-gnu/libexpat.so* /lib/${ARCH}-linux-gnu/
|
63 |
-
RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
64 |
-
COPY --chown=python:python --from=builder_global ${WORKDIR_ROOT}/.venv ${WORKDIR_ROOT}/.venv
|
65 |
-
RUN echo "check ffmpeg files..."
|
66 |
-
RUN ls -ld /usr/share/ffmpeg || echo "ffpeg folder not found!"
|
67 |
-
RUN ls -l /usr/bin/ff* || echo "ffpeg bin not found!"
|
68 |
-
RUN ls -l /usr/share/ffmpeg || echo "ffpeg folder share not found!"
|
69 |
-
RUN . ${WORKDIR_ROOT}/.venv && which python && pip list
|
70 |
-
|
71 |
-
RUN echo "new WORKDIR_ROOT after hidden venv COPY --chown=python:python => ${WORKDIR_ROOT}"
|
72 |
-
RUN ls -ld ${WORKDIR_ROOT}/
|
73 |
-
RUN ls -lA ${WORKDIR_ROOT}/
|
74 |
-
|
75 |
COPY --chown=python:python . ${WORKDIR_ROOT}/.
|
76 |
|
77 |
RUN python --version
|
@@ -87,7 +23,7 @@ RUN python -c "import pandas"
|
|
87 |
RUN python -c "from torch import Tensor"
|
88 |
RUN python -c "import gunicorn"
|
89 |
RUN df -h
|
90 |
-
RUN ls -l ${WORKDIR_ROOT}/
|
91 |
RUN ls -l ${WORKDIR_ROOT}/static/
|
92 |
|
93 |
USER 999
|
@@ -96,4 +32,4 @@ RUN echo "PATH: $PATH ..."
|
|
96 |
RUN echo "PYTHONPATH: $PYTHONPATH ..."
|
97 |
RUN echo "MPLCONFIGDIR: $MPLCONFIGDIR ..."
|
98 |
|
99 |
-
CMD ["gunicorn", "--bind", "0.0.0.0:3000", "
|
|
|
1 |
+
FROM registry.gitlab.com/aletrn/ai-pronunciation-trainer:0.5.0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
ARG ARCH
|
4 |
ARG WORKDIR_ROOT
|
|
|
8 |
|
9 |
ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
|
10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
COPY --chown=python:python . ${WORKDIR_ROOT}/.
|
12 |
|
13 |
RUN python --version
|
|
|
23 |
RUN python -c "from torch import Tensor"
|
24 |
RUN python -c "import gunicorn"
|
25 |
RUN df -h
|
26 |
+
RUN ls -l ${WORKDIR_ROOT}/webApp.py
|
27 |
RUN ls -l ${WORKDIR_ROOT}/static/
|
28 |
|
29 |
USER 999
|
|
|
32 |
RUN echo "PYTHONPATH: $PYTHONPATH ..."
|
33 |
RUN echo "MPLCONFIGDIR: $MPLCONFIGDIR ..."
|
34 |
|
35 |
+
CMD ["gunicorn", "--bind", "0.0.0.0:3000", "webApp:app"]
|
README.md
CHANGED
@@ -63,13 +63,16 @@ Build the docker image this way:
|
|
63 |
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
|
64 |
|
65 |
# build the base docker image
|
66 |
-
docker build . --progress=plain
|
|
|
|
|
|
|
67 |
```
|
68 |
|
69 |
Run the container (keep it on background) and show logs
|
70 |
|
71 |
```bash
|
72 |
-
docker run -d -p 3000:3000 --name
|
73 |
```
|
74 |
|
75 |
## Online version
|
|
|
63 |
docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
|
64 |
|
65 |
# build the base docker image
|
66 |
+
docker build . -f dockerfiles/dockerfile-base --progress=plain -t registry.gitlab.com/aletrn/ai-pronunciation-trainer:0.5.0
|
67 |
+
|
68 |
+
# build the final docker image
|
69 |
+
docker build . --progress=plain --name
|
70 |
```
|
71 |
|
72 |
Run the container (keep it on background) and show logs
|
73 |
|
74 |
```bash
|
75 |
+
docker run -d -p 3000:3000 --name aip-trainer aip-trainer;docker logs -f aip-trainer
|
76 |
```
|
77 |
|
78 |
## Online version
|
dockerfiles/dockerfile-base
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Include global ARGs at the dockerfile top
|
2 |
+
ARG ARCH="x86_64"
|
3 |
+
ARG WORKDIR_ROOT="/var/task"
|
4 |
+
|
5 |
+
|
6 |
+
FROM python:3.12-bookworm AS builder_global
|
7 |
+
|
8 |
+
ARG ARCH
|
9 |
+
ARG WORKDIR_ROOT
|
10 |
+
ARG POETRY_NO_INTERACTION
|
11 |
+
ARG POETRY_VIRTUALENVS_IN_PROJECT
|
12 |
+
ARG POETRY_VIRTUALENVS_CREATE
|
13 |
+
ARG POETRY_CACHE_DIR
|
14 |
+
ARG ZLIB1G="http://ftp.it.debian.org/debian/pool/main/z/zlib/zlib1g_1.3.dfsg-3+b1_amd64.deb"
|
15 |
+
ENV PYTHONPATH="${WORKDIR_ROOT}:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
|
16 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib
|
17 |
+
ARG USER="999"
|
18 |
+
|
19 |
+
|
20 |
+
RUN echo "ARCH: $ARCH, ARG POETRY_CACHE_DIR: ${POETRY_CACHE_DIR}, ENV PYTHONPATH: $PYTHONPATH, USER: $USER ..."
|
21 |
+
# RUN groupadd -g 999 python && useradd -r -u 999 -g python python
|
22 |
+
|
23 |
+
# Set working directory to function root directory
|
24 |
+
WORKDIR ${WORKDIR_ROOT}
|
25 |
+
COPY --chown=python:python requirements.txt ${WORKDIR_ROOT}/
|
26 |
+
|
27 |
+
# avoid segment-geospatial exception caused by missing libGL.so.1 library
|
28 |
+
RUN echo "BUILDER: check libz.s* before start" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
29 |
+
RUN apt update && apt install -y curl ffmpeg libgl1 python3-pip && apt clean
|
30 |
+
COPY --chown=python:python ./dockerfiles/apt_preferences /etc/apt/preferences
|
31 |
+
COPY --chown=python:python ./dockerfiles/debian.sources /etc/apt/sources.list.d/debian.sources
|
32 |
+
RUN apt update && apt install -t trixie zlib1g -y && apt clean
|
33 |
+
RUN echo "BUILDER: check libz.s* after install from trixie" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
34 |
+
|
35 |
+
RUN ls -l /etc/apt/sources* /etc/apt/preferences*
|
36 |
+
|
37 |
+
# poetry installation path is NOT within ${WORKDIR_ROOT}: not needed for runtime docker image
|
38 |
+
RUN python3 -m venv ${WORKDIR_ROOT}/.venv
|
39 |
+
ENV PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
|
40 |
+
RUN . ${WORKDIR_ROOT}/.venv/bin/activate && python -m pip install -r ${WORKDIR_ROOT}/requirements.txt
|
41 |
+
|
42 |
+
# USER 999
|
43 |
+
|
44 |
+
|
45 |
+
FROM python:3.12-slim-bookworm AS runtime
|
46 |
+
|
47 |
+
RUN groupadd -g 999 python && useradd -r -u 999 -g python python
|
48 |
+
|
49 |
+
ARG ARCH
|
50 |
+
ARG WORKDIR_ROOT
|
51 |
+
ENV PYTHONPATH="${WORKDIR_ROOT}:${WORKDIR_ROOT}/.venv:${PYTHONPATH}:/usr/local/lib/python3/dist-packages"
|
52 |
+
ENV MPLCONFIGDIR=/tmp/matplotlib
|
53 |
+
|
54 |
+
ENV VIRTUAL_ENV=${WORKDIR_ROOT}/.venv PATH="${WORKDIR_ROOT}/.venv/bin:$PATH"
|
55 |
+
|
56 |
+
RUN apt update && apt install -y ffmpeg && apt clean
|
57 |
+
RUN echo "COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libGL.so* /usr/lib/${ARCH}-linux-gnu/"
|
58 |
+
RUN echo "RUNTIME: check libz.s* before upgrade" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
59 |
+
RUN echo "RUNTIME: remove libz.s* to force upgrade" && rm /usr/lib/${ARCH}-linux-gnu/libz.so*
|
60 |
+
COPY --chown=python:python --from=builder_global /usr/lib/${ARCH}-linux-gnu/libz.so* /usr/lib/${ARCH}-linux-gnu/
|
61 |
+
COPY --chown=python:python --from=builder_global /lib/${ARCH}-linux-gnu/libexpat.so* /lib/${ARCH}-linux-gnu/
|
62 |
+
RUN echo "RUNTIME: check libz.s* after copy" && ls -l /usr/lib/${ARCH}-linux-gnu/libz.so*
|
63 |
+
COPY --chown=python:python --from=builder_global ${WORKDIR_ROOT}/.venv ${WORKDIR_ROOT}/.venv
|
64 |
+
RUN echo "check ffmpeg files..."
|
65 |
+
RUN ls -ld /usr/share/ffmpeg || echo "ffpeg folder not found!"
|
66 |
+
RUN ls -l /usr/bin/ff* || echo "ffpeg bin not found!"
|
67 |
+
RUN ls -l /usr/share/ffmpeg || echo "ffpeg folder share not found!"
|
68 |
+
RUN . ${WORKDIR_ROOT}/.venv && which python && pip list
|
69 |
+
|
70 |
+
RUN echo "new WORKDIR_ROOT after hidden venv COPY --chown=python:python => ${WORKDIR_ROOT}"
|
71 |
+
RUN ls -ld ${WORKDIR_ROOT}/
|
72 |
+
RUN ls -lA ${WORKDIR_ROOT}/
|