@@ -33,7 +33,7 @@ class DockerBackend(BaseBackend):
33
33
34
34
* **python_version** - set a specific version, current env. python version by default
35
35
* **keep_container_running** - stop the container right away (default) or keep it running
36
- * **apk_dependencies ** - a list of dependencies to install via alpine
36
+ * **apt_dependencies ** - a list of dependencies to install via ``apt-get``
37
37
* **disable_pull** - build all locally
38
38
* **inherit_image** - instead of using the default base Arca image, use this one
39
39
* **use_registry_name** - use this registry to store images with requirements and dependencies
@@ -42,7 +42,7 @@ class DockerBackend(BaseBackend):
42
42
43
43
python_version = LazySettingProperty (default = None )
44
44
keep_container_running = LazySettingProperty (default = False )
45
- apk_dependencies = LazySettingProperty (default = None )
45
+ apt_dependencies = LazySettingProperty (default = None )
46
46
disable_pull = LazySettingProperty (default = False ) # so the build can be tested
47
47
inherit_image = LazySettingProperty (default = None )
48
48
use_registry_name = LazySettingProperty (default = None )
@@ -60,8 +60,11 @@ class DockerBackend(BaseBackend):
60
60
61
61
INSTALL_DEPENDENCIES = """
62
62
FROM {name}:{tag}
63
- RUN apk update
64
- RUN apk add --no-cache {dependencies}
63
+ USER root
64
+ RUN apt-get update && \
65
+ apt-get install --no-install-recommends -y --autoremove {dependencies} && \
66
+ apt-get clean
67
+ USER arca
65
68
CMD bash -i
66
69
"""
67
70
@@ -80,7 +83,7 @@ def validate_settings(self):
80
83
81
84
* Checks ``inherit_image`` format.
82
85
* Checks ``use_registry_name`` format.
83
- * Checks that ``apk_dependencies `` is not set when ``inherit_image`` is set.
86
+ * Checks that ``apt_dependencies `` is not set when ``inherit_image`` is set.
84
87
85
88
:raise ArcaMisconfigured: If some of the settings aren't valid.
86
89
"""
@@ -118,17 +121,17 @@ def check_docker_access(self):
118
121
raise BuildError ("Docker is not running or the current user doesn't have permissions to access docker." )
119
122
120
123
def get_dependencies (self ) -> Optional [List [str ]]:
121
- """ Returns the ``apk_dependencies `` setting to a standardized format.
124
+ """ Returns the ``apt_dependencies `` setting to a standardized format.
122
125
123
126
:raise ArcaMisconfigured: if the dependencies can't be converted into a list of strings
124
127
:return: List of dependencies, ``None`` if there are none.
125
128
"""
126
129
127
- if not self .apk_dependencies :
130
+ if not self .apt_dependencies :
128
131
return None
129
132
130
133
try :
131
- dependencies = list ([str (x ).strip () for x in self .apk_dependencies ])
134
+ dependencies = list ([str (x ).strip () for x in self .apt_dependencies ])
132
135
except (TypeError , ValueError ):
133
136
raise ArcaMisconfigured ("Apk dependencies can't be converted into a list of strings" )
134
137
@@ -303,23 +306,34 @@ def get_arca_base(self, pull=True):
303
306
304
307
pyenv_installer = "https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer"
305
308
dockerfile = f"""
306
- FROM alpine:3.5
307
- RUN apk add --no-cache curl bash git nano g++ make jpeg-dev zlib-dev ca-certificates openssl-dev \
308
- readline-dev bzip2-dev sqlite-dev ncurses-dev linux-headers build-base \
309
- openssh
310
-
311
- RUN curl -L { pyenv_installer } -o /pyenv-installer && \
312
- touch /root/.bashrc && \
313
- /bin/ln -s /root/.bashrc /root/.bash_profile && \
314
- /bin/bash /pyenv-installer && \
315
- rm /pyenv-installer && \
316
- echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile && \
317
- echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile && \
318
- echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
319
-
320
- ENV HOME /root
321
- ENV PYENV_ROOT $HOME/.pyenv
322
- ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
309
+ FROM debian:stretch-slim
310
+ RUN apt-get update && \
311
+ apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
312
+ libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
313
+ xz-utils tk-dev libffi-dev git && \
314
+ apt-get clean
315
+
316
+ RUN adduser --system --disabled-password --shell /bin/bash arca
317
+
318
+ USER arca
319
+ WORKDIR /home/arca
320
+ RUN echo "source $HOME/.bash_profile" >> .bashrc
321
+
322
+ RUN curl -L { pyenv_installer } -o ~/pyenv-installer && \
323
+ /bin/bash ~/pyenv-installer && \
324
+ rm ~/pyenv-installer && \
325
+ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> /home/arca/.bash_profile && \
326
+ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> /home/arca/.bash_profile && \
327
+ echo 'eval "$(pyenv init -)"' >> /home/arca/.bash_profile
328
+
329
+ USER root
330
+
331
+ RUN apt-get remove -y --autoremove curl && \
332
+ apt-get clean -y
333
+
334
+ RUN mkdir /srv/scripts
335
+
336
+ USER arca
323
337
324
338
SHELL ["bash", "-lc"]
325
339
CMD bash -i
@@ -341,10 +355,10 @@ def get_dockerfile():
341
355
342
356
return f"""
343
357
FROM { base_arca_name } :{ base_arca_tag }
344
- RUN pyenv update
345
- RUN pyenv install { python_version }
358
+ RUN pyenv update && \
359
+ pyenv install { python_version }
346
360
ENV PYENV_VERSION { python_version }
347
- RUN mkdir /srv/scripts
361
+ ENV PATH "/home/arca/.pyenv/shims:$PATH"
348
362
CMD bash -i
349
363
"""
350
364
@@ -407,7 +421,7 @@ def get_image_with_installed_dependencies(self, image_name: str,
407
421
dependencies : Optional [List [str ]]) -> Tuple [str , str ]:
408
422
"""
409
423
Return name and tag of a image, based on the Arca python image, with installed dependencies defined
410
- by ``apk_dependencies ``.
424
+ by ``apt_dependencies ``.
411
425
412
426
:param image_name: Name of the image which will be ultimately used for the image.
413
427
:param dependencies: List of dependencies in the standardized format.
@@ -637,7 +651,11 @@ def start_container(self, image, container_name: str, repo_path: Path):
637
651
:type image: docker.models.images.Image
638
652
:rtype: docker.models.container.Container
639
653
"""
640
- container = self .client .containers .run (image , command = "bash -i" , detach = True , tty = True , name = container_name ,
654
+ command = "bash -i"
655
+ if self .inherit_image :
656
+ command = "sh -i"
657
+
658
+ container = self .client .containers .run (image , command = command , detach = True , tty = True , name = container_name ,
641
659
working_dir = str ((Path ("/srv/data" ) / self .cwd ).resolve ()),
642
660
auto_remove = True )
643
661
0 commit comments