smraux commited on
Commit
4484774
·
1 Parent(s): 869dccb

Update Dockerfile to use Conda environment

Browse files

This commit updates the Dockerfile to use a base image with Conda installed instead of the official Python runtime. It also adds the ability to create and activate a Conda environment from the environment.yml file. Additionally, it installs any additional dependencies specified in requirements.txt using Conda. This change improves the reproducibility and manageability of the application's dependencies.

Files changed (1) hide show
  1. Dockerfile +15 -14
Dockerfile CHANGED
@@ -1,29 +1,30 @@
1
- # Use an official Python runtime as a parent image
2
- FROM python:3.10
3
 
4
  # Set the working directory in the container
5
  WORKDIR /usr/src/app
6
 
7
- # Upgrade pip to the specified version
8
- RUN pip install --upgrade pip==23.0
9
 
10
- # Install the 'packaging' package using pip
11
- RUN pip install packaging
12
 
13
- RUN pip install pygit2
14
- RUN pip install numpy
15
 
16
- # Copy the current directory contents into the container at /usr/src/app
17
  COPY . .
18
 
19
- # Install any needed packages specified in requirements.txt
20
- RUN pip install --no-cache-dir -r requirements.txt
 
21
 
22
  # Make port 80 available to the world outside this container
23
  EXPOSE 80
24
 
25
- # Define environment variable
26
  ENV NAME World
27
 
28
- # Run app.py when the container launches
29
- CMD ["python", "./entry_with_update.py","--preset","realistic"]
 
1
+ # Use a base image with Conda installed
2
+ FROM continuumio/miniconda3
3
 
4
  # Set the working directory in the container
5
  WORKDIR /usr/src/app
6
 
7
+ # Copy the environment.yml file to the container
8
+ COPY environment.yml ./
9
 
10
+ # Create the Conda environment from the environment.yml file
11
+ RUN conda env create -f environment.yml && conda clean -afy
12
 
13
+ # Activate the environment
14
+ SHELL ["conda", "run", "-n", "fooocus", "/bin/bash", "-c"]
15
 
16
+ # Copy the rest of your application's code
17
  COPY . .
18
 
19
+ # Install any additional dependencies specified in requirements.txt
20
+ # Note: This is only necessary if you have additional pip packages not listed in environment.yml
21
+ RUN conda run -n fooocus pip install --no-cache-dir -r requirements.txt
22
 
23
  # Make port 80 available to the world outside this container
24
  EXPOSE 80
25
 
26
+ # Define environment variable (if needed)
27
  ENV NAME World
28
 
29
+ # Run your application
30
+ CMD ["conda", "run", "-n", "fooocus", "python", "./entry_with_update.py", "--preset", "realistic"]