Skip to content

Commit df733fc

Browse files
bollwyvlconsideRatio
authored andcommitted
normalize ENV syntax, combine more layers
1 parent 803a1c2 commit df733fc

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

repo2docker/buildpacks/base.py

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,18 @@
2727
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
2828
locale-gen
2929
30-
ENV LC_ALL en_US.UTF-8
31-
ENV LANG en_US.UTF-8
32-
ENV LANGUAGE en_US.UTF-8
30+
ENV LC_ALL=en_US.UTF-8 \
31+
LANG=en_US.UTF-8 \
32+
LANGUAGE=en_US.UTF-8
3333
3434
# Use bash as default shell, rather than sh
35-
ENV SHELL /bin/bash
35+
ENV SHELL=/bin/bash
3636
3737
# Set up user
3838
ARG NB_USER
3939
ARG NB_UID
40-
ENV USER ${NB_USER}
41-
ENV HOME /home/${NB_USER}
40+
ENV USER=${NB_USER} \
41+
HOME=/home/${NB_USER}
4242
4343
RUN groupadd \
4444
--gid ${NB_UID} \
@@ -81,13 +81,13 @@
8181
{% if build_env -%}
8282
# Environment variables required for build
8383
{% for item in build_env -%}
84-
ENV {{item[0]}} {{item[1]}}
84+
ENV {{item[0]}}={{item[1]}}
8585
{% endfor -%}
8686
{% endif -%}
8787
8888
{% if path -%}
8989
# Special case PATH
90-
ENV PATH {{ ':'.join(path) }}:${PATH}
90+
ENV PATH={{ ':'.join(path) }}:${PATH}
9191
{% endif -%}
9292
9393
{% if build_script_files -%}
@@ -105,9 +105,15 @@
105105
106106
# Allow target path repo is cloned to be configurable
107107
ARG REPO_DIR=${HOME}
108-
RUN [ ! -d ${REPO_DIR} ] \
109-
&& mkdir -p ${REPO_DIR} \
110-
&& chown -R ${NB_USER}:${NB_USER} ${REPO_DIR}
108+
ENV REPO_DIR=${REPO_DIR}
109+
RUN if [ ! -d "${REPO_DIR}" ] \
110+
; then \
111+
mkdir -p "${REPO_DIR}" \
112+
&& chown -R ${NB_USER}:${NB_USER} "${REPO_DIR}" \
113+
; else \
114+
echo "${REPO_DIR} already exists..." \
115+
; fi
116+
111117
WORKDIR ${REPO_DIR}
112118
RUN chown ${NB_USER}:${NB_USER} ${REPO_DIR}
113119
@@ -119,12 +125,12 @@
119125
#
120126
# The XDG standard suggests ~/.local/bin as the path for local user-specific
121127
# installs. See https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
122-
ENV PATH ${HOME}/.local/bin:${REPO_DIR}/.local/bin:${PATH}
128+
ENV PATH=${HOME}/.local/bin:${REPO_DIR}/.local/bin:${PATH}
123129
124130
{% if env -%}
125131
# The rest of the environment
126132
{% for item in env -%}
127-
ENV {{item[0]}} {{item[1]}}
133+
ENV {{item[0]}}={{item[1]}}
128134
{% endfor -%}
129135
{% endif -%}
130136
@@ -175,7 +181,7 @@
175181
# Add start script
176182
{% if start_script is not none -%}
177183
RUN chmod +x "{{ start_script }}"
178-
ENV R2D_ENTRYPOINT "{{ start_script }}"
184+
ENV R2D_ENTRYPOINT="{{ start_script }}"
179185
{% endif -%}
180186
181187
# Add entrypoint

0 commit comments

Comments
 (0)