Skip to content

Commit

Permalink
feat: add docker container (#379)
Browse files Browse the repository at this point in the history
This pull request adds a docker container that can be used to run the
SLC package. This was done to improve the reproducibility of results.
  • Loading branch information
rickstaa authored Jan 19, 2024
1 parent c3b47c5 commit 972079f
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
26 changes: 26 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"build": {
"context": "..",
"dockerfile": "../Dockerfile"
},
"runArgs": [
"-e",
"DISPLAY=${localEnv:DISPLAY}",
"-v",
"/tmp/.X11-unix:/tmp/.X11-unix:ro"
],
"customizations": {
"vscode": {
"extensions": [
"ms-python.python"
]
},
"settings": {
"python.pythonpath": "/opt/conda/envs/han2020/bin/python"
}
},
"postCreateCommand": "echo 'If you need to run GUI applications inside this Docker container, remember to execute `xhost +local:docker` on your host machine to enable X11 forwarding. You can remove it again with `xhost -local:docker` when you are done.'"
}
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Use the official Miniconda3 base image
FROM continuumio/miniconda3:latest

# Set environment variables for Conda
ENV CONDA_HOME="/opt/conda"
ENV PATH="$CONDA_HOME/bin:$PATH"

# Install system dependencies
RUN apt-get update && apt-get install -y \
libopenmpi-dev \
&& rm -rf /var/lib/apt/lists/*

# Create a Conda environment with Python 3.10
RUN conda create -n slc python=3.10

# Activate the Conda environment
SHELL ["conda", "run", "-n", "slc", "/bin/bash", "-c"]

# Copy the repo code into the Docker image
COPY . /stable-learning-control

# Clone stable-gym package
RUN git clone https://github.com/rickstaa/stable-gym.git

# Set the working directory
WORKDIR /stable-learning-control

# Install mpi4py using Conda
# NOTE: Done since the pip version of mpi4py does not to seem to work in a Conda environment.
RUN conda install mpi4py

# Install slc package
# RUN pip install -e .
RUN pip install -e .[mujoco]

# Install the stable-gym package
RUN pip install -e ../stable-gym

# Add Conda activation to .bashrc (optional)
RUN echo "source activate slc" >> /root/.bashrc

# Start the experiments
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "slc", "python", "-m", "stable_learning_control.run"]

0 comments on commit 972079f

Please sign in to comment.