Skip to content

Commit 3f976a6

Browse files
committed
improve devcontainer build speed
1 parent 20518eb commit 3f976a6

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
- name: Install Docker
2+
hosts: localhost
3+
connection: local
4+
gather_facts: true
5+
become: true
6+
vars:
7+
# docker defaults
8+
docker_edition: 'ce'
9+
docker_package_state: present
10+
docker_service_manage: false
11+
docker_install_compose_plugin: true
12+
docker_compose_package: docker-compose-plugin
13+
docker_compose_package_state: present
14+
15+
docker_users:
16+
- "{{ lookup('env', 'USER') }}"
17+
roles:
18+
- role: geerlingguy.docker

.devcontainer/ansible/roles/setup-container/meta/main.yml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.devcontainer/requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

Dockerfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
4242
libopenblas-dev \
4343
locales \
4444
make \
45-
sudo \
4645
tzdata \
4746
zsh && \
4847
# cleanup
@@ -59,6 +58,8 @@ RUN sed -i 's/UID_MAX .*/UID_MAX 100000/' /etc/login.defs && \
5958
echo "PS1='\h:\$(pwd) \$ '" >> /etc/zshenv && \
6059
mkdir -p ${PROJECT_PATH} && \
6160
chown -R ${USER}:${USER} ${PROJECT_PATH} && \
61+
# set the shell for root too
62+
chsh -s /bin/${TERM_SHELL} && \
6263
# https://www.jeffgeerling.com/blog/2023/how-solve-error-externally-managed-environment-when-installing-pip3
6364
rm -rf /usr/lib/python${PYTHON_VERSION}/EXTERNALLY-MANAGED
6465

@@ -154,6 +155,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
154155
ripgrep \
155156
rsync \
156157
sshpass \
158+
sudo \
157159
tar \
158160
tree \
159161
util-linux \
@@ -163,7 +165,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
163165
apt-get autoremove -fy && \
164166
apt-get clean && \
165167
apt-get autoclean -y && \
166-
rm -rf /var/lib/apt/lists/*
168+
rm -rf /var/lib/apt/lists/* && \
169+
echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} && \
170+
chmod 0440 /etc/sudoers.d/${USER}
167171

168172
RUN apt-get update && apt-get install -y --no-install-recommends \
169173
graphviz \
@@ -183,17 +187,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
183187
apt-get autoclean -y && \
184188
rm -rf /var/lib/apt/lists/*
185189

186-
RUN pip3 install --target=${PYTHON_DEPS_PATH} ipython ipykernel docutils jupyter notebook jupyterhub && \
187-
pip3 install --target=${PYTHON_DEPS_PATH} watermark pyyaml pylint h5py tensorflow && \
188-
pip3 install --target=${PYTHON_DEPS_PATH} --no-deps --prefer-binary matplotlib seaborn plotly graphviz opencv-python-headless imutils keras && \
189-
pip3 install --target=${PYTHON_DEPS_PATH} --prefer-binary pandas-datareader bottleneck scipy scikit-learn duckdb sqlalchemy pyautogui requests_cache statsmodels
190-
191-
COPY .devcontainer/requirements.txt requirements.txt
192-
RUN pip3 install --no-cache-dir --target=${PYTHON_DEPS_PATH} -r requirements.txt && \
193-
rm -rf requirements.txt
190+
RUN pip3 install --no-cache-dir --target=${PYTHON_DEPS_PATH} docutils h5py ipykernel ipython jupyter jupyterhub notebook numpy nltk pyyaml pylint scikit-learn scipy==1.11.0 watermark
191+
RUN pip3 install --no-cache-dir --target=${PYTHON_DEPS_PATH} --no-deps --prefer-binary matplotlib seaborn plotly graphviz imutils keras
192+
RUN pip3 install --no-cache-dir --target=${PYTHON_DEPS_PATH} --prefer-binary pandas-datareader bottleneck scipy duckdb sqlalchemy pyautogui requests_cache statsmodels
193+
#RUN pip3 install --no-cache-dir --target=${PYTHON_DEPS_PATH} gensim torch tensorflow
194194

195-
RUN echo ${USER} ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/${USER} && \
196-
chmod 0440 /etc/sudoers.d/${USER}
195+
RUN LC_ALL=C.UTF-8 ansible-playbook --inventory 127.0.0.1 --connection=local .devcontainer/ansible/requirements.yml && \
196+
LC_ALL=C.UTF-8 ansible-playbook --inventory 127.0.0.1 --connection=local .devcontainer/ansible/install-docker.yml
197197

198198
USER ${USER}
199199

0 commit comments

Comments
 (0)