Skip to content

Commit

Permalink
Use new IN_DOCKER_CONTAINER variable
Browse files Browse the repository at this point in the history
  • Loading branch information
bbfrederick committed Nov 15, 2024
1 parent 42eddd1 commit 80b196b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
19 changes: 14 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,29 @@ RUN ldconfig
# clean up
RUN pip cache purge

# switch to the rapidtide user
RUN useradd -m -s /bin/bash -G users rapidtide
RUN chown -R rapidtide /src/rapidtide
WORKDIR /home/rapidtide
# Create a shared $HOME directory
ENV USER=rapidtide
RUN useradd \
--create-home \
--shell /bin/bash \
--groups users \
--home /home/$USER \
$USER
RUN chown -R $USER /src/$USER
WORKDIR /home/$USER
ENV HOME="/home/rapidtide"

RUN /opt/miniforge3/bin/mamba init
RUN echo "mamba activate science" >> /home/rapidtide/.bashrc
RUN echo "/opt/miniforge3/bin/mamba activate science" >> /home/rapidtide/.bashrc

# switch to the rapidtide user
USER rapidtide

# set up variable for non-interactive shell
ENV PATH=/opt/miniforge3/envs/science/bin:/opt/miniforge3/condabin:.:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

ENV IS_DOCKER_8395080871=1
ENV IN_DOCKER_CONTAINER=1

WORKDIR /tmp/
ENTRYPOINT ["/cloud/mount-and-run"]
Expand Down
2 changes: 1 addition & 1 deletion rapidtide/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def version():
"""
try:
dummy = os.environ["IS_DOCKER_8395080871"]
dummy = os.environ["IN_DOCKER_CONTAINER"]
except KeyError:
isdocker = False
else:
Expand Down
2 changes: 1 addition & 1 deletion rapidtide/workflows/happy.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def happy_main(argparsingfunc):

# if we are running in a Docker container, make sure we enforce memory limits properly
try:
testval = os.environ["IS_DOCKER_8395080871"]
testval = os.environ["IN_DOCKER_CONTAINER"]
except KeyError:
args.runningindocker = False
else:
Expand Down
2 changes: 1 addition & 1 deletion rapidtide/workflows/rapidtide.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ def rapidtide_main(argparsingfunc):
print("turning on garbage collection")

# if we are running in a Docker container, make sure we enforce memory limits properly
if "IS_DOCKER_8395080871" in os.environ:
if "IN_DOCKER_CONTAINER" in os.environ:
optiondict["runningindocker"] = True
optiondict["dockermemfree"], optiondict["dockermemswap"] = tide_util.findavailablemem()
if optiondict["dockermemfix"]:
Expand Down

0 comments on commit 80b196b

Please sign in to comment.