afshin-dini commited on
Commit
df97efe
·
1 Parent(s): 21866b4

Clean Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +143 -143
Dockerfile CHANGED
@@ -1,143 +1,143 @@
1
- ## syntax=docker/dockerfile:1.1.7-experimental
2
-
3
- ################
4
- # Base builder #
5
- ################
6
- FROM python:3.10-bookworm as base_build
7
-
8
- ENV \
9
- # locale environment variables
10
- LC_ALL=C.UTF-8 \
11
- # python environemnt variables
12
- PYTHONFAULTHANDLER=1 \
13
- PYTHONUNBUFFERED=1 \
14
- PYTHONHASHSEED=random \
15
- # pip environmental variables
16
- PIP_NO_CACHE_DIR=off \
17
- PIP_DISABLE_PIP_VERSION_CHECK=on \
18
- PIP_DEFAULT_TIMEOUT=100 \
19
- # poetry version
20
- POETRY_VERSION=1.5.0
21
-
22
- # Install requirements
23
- RUN apt-get update && apt-get install -y \
24
- curl \
25
- git \
26
- bash \
27
- build-essential \
28
- libffi-dev \
29
- libssl-dev \
30
- tini \
31
- openssh-client \
32
- cargo \
33
- musl-dev \
34
- && apt-get autoremove -y \
35
- && rm -rf /var/lib/apt/lists/* \
36
- # github ssh key setting
37
- && mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com | sort > ~/.ssh/known_hosts \
38
- # Installing poetry and set the PATH
39
- && curl -sSL https://install.python-poetry.org | python3 - \
40
- && echo 'export PATH="/root/.local/bin:$PATH"' >>/root/.profile \
41
- && export PATH="/root/.local/bin:$PATH" \
42
- && true
43
- SHELL ["/bin/bash", "-lc"]
44
-
45
- # Copy poetry lock and pyproject config files to the container
46
- WORKDIR /pysetup
47
- COPY ./poetry.lock ./pyproject.toml /pysetup/
48
- # Install pip/wheel/virtualenv and build the wheels based on the poetry lock
49
- RUN --mount=type=ssh pip3 install wheel virtualenv poetry-plugin-export \
50
- && poetry export -f requirements.txt --without-hashes -o /tmp/requirements.txt \
51
- && pip3 wheel --wheel-dir=/tmp/wheelhouse --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ -r /tmp/requirements.txt \
52
- && virtualenv /.venv && source /.venv/bin/activate && echo 'source /.venv/bin/activate' >>/root/.profile \
53
- && pip3 install --no-deps --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ --find-links=/tmp/wheelhouse/ /tmp/wheelhouse/*.whl \
54
- && true
55
-
56
-
57
- ###########################
58
- # Production base builder #
59
- ###########################
60
- FROM base_build as production_build
61
- # Copy entrypoint script to the container and src files to the app directory
62
- COPY ./docker/entrypoint.sh /docker-entrypoint.sh
63
- COPY . /app/
64
- WORKDIR /app
65
- # Build the wheel packages with poetry and add them to the wheelhouse
66
- RUN --mount=type=ssh source /.venv/bin/activate \
67
- && poetry build -f wheel --no-interaction --no-ansi \
68
- && cp dist/*.whl /tmp/wheelhouse \
69
- && chmod a+x /docker-entrypoint.sh \
70
- && true
71
-
72
-
73
-
74
- ########################
75
- # Production Container #
76
- ########################
77
- FROM python:3.10-bookworm as production
78
- COPY --from=production_build /tmp/wheelhouse /tmp/wheelhouse
79
- COPY --from=production_build /docker-entrypoint.sh /docker-entrypoint.sh
80
- WORKDIR /app
81
- # Install system level deps for running the package and install the wheels we built in the previous step.
82
- RUN --mount=type=ssh apt-get update && apt-get install -y \
83
- bash \
84
- libffi8 \
85
- libgl1 \
86
- tini \
87
- && apt-get autoremove -y \
88
- && rm -rf /var/lib/apt/lists/* \
89
- && chmod a+x /docker-entrypoint.sh \
90
- && WHEELFILE=`echo /tmp/wheelhouse/deep_package_detection-*.whl` \
91
- && pip3 install --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ --find-links=/tmp/wheelhouse/ "$WHEELFILE"[all] \
92
- && rm -rf /tmp/wheelhouse/ \
93
- && true
94
- ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
95
-
96
-
97
-
98
- ############################
99
- # Development base builder #
100
- ############################
101
- FROM base_build as development_build
102
- # Copy src to app directory
103
- COPY . /app
104
- WORKDIR /app
105
- # Install dependencies from poetry lock
106
- RUN --mount=type=ssh source /.venv/bin/activate \
107
- && apt-get update && apt-get install -y libgl1 \
108
- && export PIP_FIND_LINKS=http://172.17.0.1:3141/debian/ \
109
- && export PIP_TRUSTED_HOST=172.17.0.1 \
110
- && pip3 install nvidia-cublas-cu12 nvidia-cusparse-cu12 triton nvidia-nccl-cu12 nvidia-cudnn-cu12 nvidia-cufft-cu12 nvidia-cusolver-cu12 \
111
- && poetry install --no-interaction --no-ansi \
112
- && true
113
-
114
-
115
-
116
- ###################
117
- # Tests Container #
118
- ###################
119
- FROM development_build as test
120
- RUN --mount=type=ssh source /.venv/bin/activate \
121
- && chmod a+x docker/*.sh \
122
- && docker/pre_commit_init.sh \
123
- && true
124
- ENTRYPOINT ["/usr/bin/tini", "--", "docker/entrypoint-test.sh"]
125
-
126
-
127
- #########################
128
- # Development Container #
129
- #########################
130
- FROM development_build as development
131
- RUN apt-get update && apt-get install -y zsh \
132
- && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
133
- && echo "if [ \"\$NO_WHEELHOUSE\" = \"1\" ]" >>/root/.profile \
134
- && echo "then" >>/root/.profile \
135
- && echo " echo \"Wheelhouse disabled\"" >>/root/.profile \
136
- && echo "else">>/root/.profile \
137
- && echo " export PIP_TRUSTED_HOST=172.17.0.1" >>/root/.profile \
138
- && echo " export PIP_FIND_LINKS=http://172.17.0.1:3141/debian/" >>/root/.profile \
139
- && echo "fi" >>/root/.profile \
140
- && echo "source /root/.profile" >>/root/.zshrc \
141
- && pip3 install git-up \
142
- && true
143
- ENTRYPOINT ["/bin/zsh", "-l"]
 
1
+ ## syntax=docker/dockerfile:1.1.7-experimental
2
+
3
+ ################
4
+ # Base builder #
5
+ ################
6
+ FROM python:3.10-bookworm as base_build
7
+
8
+ ENV \
9
+ # locale environment variables
10
+ LC_ALL=C.UTF-8 \
11
+ # python environemnt variables
12
+ PYTHONFAULTHANDLER=1 \
13
+ PYTHONUNBUFFERED=1 \
14
+ PYTHONHASHSEED=random \
15
+ # pip environmental variables
16
+ PIP_NO_CACHE_DIR=off \
17
+ PIP_DISABLE_PIP_VERSION_CHECK=on \
18
+ PIP_DEFAULT_TIMEOUT=100 \
19
+ # poetry version
20
+ POETRY_VERSION=1.5.0
21
+
22
+ # Install requirements
23
+ RUN apt-get update && apt-get install -y \
24
+ curl \
25
+ git \
26
+ bash \
27
+ build-essential \
28
+ libffi-dev \
29
+ libssl-dev \
30
+ tini \
31
+ openssh-client \
32
+ cargo \
33
+ musl-dev \
34
+ && apt-get autoremove -y \
35
+ && rm -rf /var/lib/apt/lists/* \
36
+ # github ssh key setting
37
+ && mkdir -p -m 0700 ~/.ssh && ssh-keyscan github.com | sort > ~/.ssh/known_hosts \
38
+ # Installing poetry and set the PATH
39
+ && curl -sSL https://install.python-poetry.org | python3 - \
40
+ && echo 'export PATH="/root/.local/bin:$PATH"' >>/root/.profile \
41
+ && export PATH="/root/.local/bin:$PATH" \
42
+ && true
43
+ SHELL ["/bin/bash", "-lc"]
44
+
45
+ # Copy poetry lock and pyproject config files to the container
46
+ WORKDIR /pysetup
47
+ COPY ./poetry.lock ./pyproject.toml /pysetup/
48
+ # Install pip/wheel/virtualenv and build the wheels based on the poetry lock
49
+ RUN --mount=type=ssh pip3 install wheel virtualenv poetry-plugin-export \
50
+ && poetry export -f requirements.txt --without-hashes -o /tmp/requirements.txt \
51
+ && pip3 wheel --wheel-dir=/tmp/wheelhouse --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ -r /tmp/requirements.txt \
52
+ && virtualenv /.venv && source /.venv/bin/activate && echo 'source /.venv/bin/activate' >>/root/.profile \
53
+ && pip3 install --no-deps --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ --find-links=/tmp/wheelhouse/ /tmp/wheelhouse/*.whl \
54
+ && true
55
+
56
+
57
+ ###########################
58
+ # Production base builder #
59
+ ###########################
60
+ FROM base_build as production_build
61
+ # Copy entrypoint script to the container and src files to the app directory
62
+ COPY ./docker/entrypoint.sh /docker-entrypoint.sh
63
+ COPY . /app/
64
+ WORKDIR /app
65
+ # Build the wheel packages with poetry and add them to the wheelhouse
66
+ RUN --mount=type=ssh source /.venv/bin/activate \
67
+ && poetry build -f wheel --no-interaction --no-ansi \
68
+ && cp dist/*.whl /tmp/wheelhouse \
69
+ && chmod a+x /docker-entrypoint.sh \
70
+ && true
71
+
72
+
73
+
74
+ ########################
75
+ # Production Container #
76
+ ########################
77
+ FROM python:3.10-bookworm as production
78
+ COPY --from=production_build /tmp/wheelhouse /tmp/wheelhouse
79
+ COPY --from=production_build /docker-entrypoint.sh /docker-entrypoint.sh
80
+ WORKDIR /app
81
+ # Install system level deps for running the package and install the wheels we built in the previous step.
82
+ RUN --mount=type=ssh apt-get update && apt-get install -y \
83
+ bash \
84
+ libffi8 \
85
+ libgl1 \
86
+ tini \
87
+ && apt-get autoremove -y \
88
+ && rm -rf /var/lib/apt/lists/* \
89
+ && chmod a+x /docker-entrypoint.sh \
90
+ && WHEELFILE=`echo /tmp/wheelhouse/deep_package_detection-*.whl` \
91
+ && pip3 install --trusted-host 172.17.0.1 --find-links=http://172.17.0.1:3141/debian/ --find-links=/tmp/wheelhouse/ "$WHEELFILE"[all] \
92
+ && rm -rf /tmp/wheelhouse/ \
93
+ && true
94
+ ENTRYPOINT ["/usr/bin/tini", "--", "/docker-entrypoint.sh"]
95
+
96
+
97
+
98
+ ############################
99
+ # Development base builder #
100
+ ############################
101
+ FROM base_build as development_build
102
+ # Copy src to app directory
103
+ COPY . /app
104
+ WORKDIR /app
105
+ # Install dependencies from poetry lock
106
+ RUN --mount=type=ssh source /.venv/bin/activate \
107
+ && apt-get update && apt-get install -y libgl1 \
108
+ && export PIP_FIND_LINKS=http://172.17.0.1:3141/debian/ \
109
+ && export PIP_TRUSTED_HOST=172.17.0.1 \
110
+ && pip3 install nvidia-cublas-cu12 nvidia-cusparse-cu12 triton nvidia-nccl-cu12 nvidia-cudnn-cu12 nvidia-cufft-cu12 nvidia-cusolver-cu12 \
111
+ && poetry install --no-interaction --no-ansi \
112
+ && true
113
+
114
+
115
+
116
+ ###################
117
+ # Tests Container #
118
+ ###################
119
+ FROM development_build as test
120
+ RUN --mount=type=ssh source /.venv/bin/activate \
121
+ && chmod a+x docker/*.sh \
122
+ && docker/pre_commit_init.sh \
123
+ && true
124
+ ENTRYPOINT ["/usr/bin/tini", "--", "docker/entrypoint-test.sh"]
125
+
126
+
127
+ #########################
128
+ # Development Container #
129
+ #########################
130
+ FROM development_build as development
131
+ RUN apt-get update && apt-get install -y zsh \
132
+ && sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" \
133
+ && echo "if [ \"\$NO_WHEELHOUSE\" = \"1\" ]" >>/root/.profile \
134
+ && echo "then" >>/root/.profile \
135
+ && echo " echo \"Wheelhouse disabled\"" >>/root/.profile \
136
+ && echo "else">>/root/.profile \
137
+ && echo " export PIP_TRUSTED_HOST=172.17.0.1" >>/root/.profile \
138
+ && echo " export PIP_FIND_LINKS=http://172.17.0.1:3141/debian/" >>/root/.profile \
139
+ && echo "fi" >>/root/.profile \
140
+ && echo "source /root/.profile" >>/root/.zshrc \
141
+ && pip3 install git-up \
142
+ && true
143
+ ENTRYPOINT ["/bin/zsh", "-l"]