Skip to content

Commit 0cdafae

Browse files
committed
fix: run docker/podman container once
Instead of running multiple containers it is enough to use just one. Signed-off-by: Evgeny Semenov <[email protected]>
1 parent cbcb87e commit 0cdafae

File tree

2 files changed

+22
-10
lines changed

2 files changed

+22
-10
lines changed

bin/setup

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@ CONTAINER_TAG=`cat ${ROOT}/bin/.container-tag`
99
# Parse command line arguments
1010
PRESERVE_CONFIG=0
1111

12+
CONTAINER_SETUP_CMD=()
13+
run() {
14+
if [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
15+
CONTAINER_SETUP_CMD+=( "$*" )
16+
else
17+
${RUN} "$@"
18+
fi
19+
}
20+
1221
# Only parse arguments if this script is being run directly (not sourced)
1322
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
1423
for arg in "$@"; do
@@ -159,10 +168,8 @@ if [ -f $ROOT/.git ]; then
159168
HOME_OPT="${HOME_OPT} --bind ${GIT_PATH}:${GIT_PATH}"
160169
fi
161170

162-
if [ "${CONTAINER_TYPE}" == "devcontainer" ]; then
171+
if [ "${CONTAINER_TYPE}" == "devcontainer" -o "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
163172
RUN=""
164-
elif [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
165-
RUN="${CONTAINER_BASE}"
166173
elif [ "${CONTAINER_TYPE}" == "singularity" ]; then
167174
RUN="singularity run ${HOME_OPT} ${CONTAINER_PATH}"
168175
else
@@ -180,16 +187,16 @@ if [ $PRESERVE_CONFIG -eq 0 ] || [ ! -f $ROOT/.bundle/config ]; then
180187
fi
181188
OLDDIR=$PWD
182189
cd $ROOT
183-
${RUN} bundle config set --local path ${ROOT}/.home/.gems
184-
${RUN} bundle config set --local cache_path ${ROOT}/.home/.cache
185-
${RUN} bundle config set --local with development
190+
run bundle config set --local path ${ROOT}/.home/.gems
191+
run bundle config set --local cache_path ${ROOT}/.home/.cache
192+
run bundle config set --local with development
186193
cd $OLDDIR
187194
fi
188195

189196
if [ ! -d $ROOT/.home/.gems ]; then
190197
OLDDIR=$PWD
191198
cd $ROOT
192-
${RUN} bundle install
199+
run bundle install
193200
cd $OLDDIR
194201
fi
195202

@@ -203,8 +210,8 @@ fi
203210

204211
if [[ ! -z "$DEVELOPMENT" && $DEVELOPMENT -eq 1 ]]; then
205212
if [ ! -d "${ROOT}/.home/.yard/gem_index" ]; then
206-
${RUN} bundle exec --gemfile ${ROOT}/Gemfile yard config --gem-install-yri
207-
${RUN} bundle exec --gemfile ${ROOT}/Gemfile yard gems
213+
run bundle exec --gemfile ${ROOT}/Gemfile yard config --gem-install-yri
214+
run bundle exec --gemfile ${ROOT}/Gemfile yard gems
208215
touch ${ROOT}/.stamps/dev_gems
209216
fi
210217
fi

do

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,9 @@ fi
1818
source $ROOT/bin/setup
1919

2020
# really long way of invoking rake, but renamed to 'do'
21-
$BUNDLE exec --gemfile $ROOT/Gemfile ruby -r rake -e "Rake.application.init('do');Rake.application.load_rakefile;Rake.application.top_level" -- "$@"
21+
EXEC=( exec --gemfile "$ROOT/Gemfile" ruby -r rake -e '"Rake.application.init('"'do'"');Rake.application.load_rakefile;Rake.application.top_level"' -- "$@" )
22+
if [ "${CONTAINER_TYPE}" == "docker" -o "${CONTAINER_TYPE}" == "podman" ]; then
23+
${BASH} -c "$(printf "%s && " "${CONTAINER_SETUP_CMD[@]:-true}") bundle ${EXEC[*]}"
24+
else
25+
$BUNDLE "${EXEC[@]}"
26+
fi

0 commit comments

Comments
 (0)