parokshsaxena commited on
Commit
55145c7
1 Parent(s): b436f14

based on chatGPT suggestions

Browse files
Files changed (2) hide show
  1. Dockerfile +12 -11
  2. run.sh +6 -4
Dockerfile CHANGED
@@ -1,19 +1,21 @@
1
  FROM continuumio/anaconda3:main
2
 
 
3
  WORKDIR /code
 
 
4
  COPY ./environment.yml /code/environment.yml
5
 
6
- # Create the environment using the environment.yml file
7
  RUN conda env create -f /code/environment.yml
8
 
9
- # Make RUN commands use the new environment: From ChatGPT
10
- SHELL ["conda", "run", "-n", "idm", "/bin/bash", "-c"]
11
-
12
  # Set up a new user named "user" with user ID 1000
13
  RUN useradd -m -u 1000 user
 
14
  # Switch to the "user" user
15
  USER user
16
- # Set home to the user's home directory
 
17
  ENV HOME=/home/user \
18
  PYTHONPATH=$HOME/app \
19
  PYTHONUNBUFFERED=1 \
@@ -26,12 +28,11 @@ ENV HOME=/home/user \
26
  # Set the working directory to the user's home directory
27
  WORKDIR $HOME/app
28
 
29
- # Copy the current directory contents into the container at $HOME/app setting the owner to the user
30
  COPY --chown=user . $HOME/app
31
 
32
- # From ChatGPT
33
- # CMD ["./run.sh"]
34
- # Make sure conda is initialized for the user
35
- RUN echo "conda activate idm" >> ~/.bashrc
36
 
37
- CMD ["conda", "run", "--no-capture-output", "-n", "idm", "./run.sh"]
 
 
1
  FROM continuumio/anaconda3:main
2
 
3
+ # Set the working directory inside the container
4
  WORKDIR /code
5
+
6
+ # Copy the environment.yml file into the container
7
  COPY ./environment.yml /code/environment.yml
8
 
9
+ # Create the conda environment using the environment.yml file
10
  RUN conda env create -f /code/environment.yml
11
 
 
 
 
12
  # Set up a new user named "user" with user ID 1000
13
  RUN useradd -m -u 1000 user
14
+
15
  # Switch to the "user" user
16
  USER user
17
+
18
+ # Set environment variables
19
  ENV HOME=/home/user \
20
  PYTHONPATH=$HOME/app \
21
  PYTHONUNBUFFERED=1 \
 
28
  # Set the working directory to the user's home directory
29
  WORKDIR $HOME/app
30
 
31
+ # Copy the current directory contents into the container at $HOME/app, setting the owner to the user
32
  COPY --chown=user . $HOME/app
33
 
34
+ # Ensure conda is initialized for the user
35
+ RUN echo "source activate idm" >> ~/.bashrc
 
 
36
 
37
+ # Set the entry point to run.sh
38
+ ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "idm", "/bin/bash", "./run.sh"]
run.sh CHANGED
@@ -1,5 +1,7 @@
1
  #!/bin/bash
2
- CONDA_ENV=$(head -1 /code/environment.yml | cut -d" " -f2)
3
- eval "$(conda shell.bash hook)"
4
- conda activate $CONDA_ENV
5
- python app.py
 
 
 
1
  #!/bin/bash
2
+
3
+ # Activate the conda environment
4
+ source activate idm
5
+
6
+ # Run your application
7
+ python gradio_demo/app.py