arthurcornelio88 commited on
Commit
0a448ee
·
1 Parent(s): 96028f8

Add Dockerfile for GCP

Browse files
Files changed (2) hide show
  1. Dockerfile +50 -0
  2. requirements.txt +7 -0
Dockerfile ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Build from a LINUX lightweight version of Anaconda
2
+ FROM continuumio/miniconda3
3
+
4
+ # Update packages and install necessary utilities
5
+ RUN apt-get update && apt-get install -y nano unzip curl
6
+
7
+ # Install gcloud CLI - Necessary for interacting with GCP
8
+ RUN curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
9
+ RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] http://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
10
+ RUN apt-get update && apt-get install -y google-cloud-sdk
11
+
12
+ # Create a non-root user (Hugging Face requirement)
13
+ RUN useradd -m -u 1000 user
14
+ USER user
15
+ ENV HOME=/home/user \
16
+ PATH=/home/user/.local/bin:$PATH
17
+
18
+ WORKDIR $HOME/app
19
+
20
+ # Copy files with correct ownership for Hugging Face
21
+ COPY --chown=user . $HOME/app
22
+
23
+ # Copy and install dependencies
24
+ COPY requirements.txt /requirements.txt
25
+ RUN pip install -r /requirements.txt
26
+
27
+ # Set GCP project and other environment variables
28
+ # Note: These should be passed as build arguments or environment variables when running the container.
29
+ # It's NOT recommended to hardcode sensitive information in the Dockerfile.
30
+ ARG GCP_PROJECT
31
+ ENV GCP_PROJECT=$GCP_PROJECT
32
+ ENV BACKEND_STORE_URI=$BACKEND_STORE_URI
33
+ ENV ARTIFACT_STORE_URI=$ARTIFACT_STORE_URI
34
+
35
+ # Authenticate with gcloud (using service account recommended for production)
36
+ # Option 1: Using a service account key file (Recommended for production)
37
+ COPY service_account.json $HOME/app/service_account.json # Copy the key file
38
+ RUN gcloud auth activate-service-account --key-file=$HOME/app/service_account.json
39
+
40
+ # Option 2: Using application default credentials (For local development or testing)
41
+ # RUN gcloud auth application-default login
42
+
43
+ # Make sure the gcloud CLI is initialized.
44
+ RUN gcloud init --quiet
45
+
46
+ # Launch mlflow server
47
+ CMD mlflow server -p $PORT \
48
+ --host 0.0.0.0 \
49
+ --backend-store-uri $BACKEND_STORE_URI \
50
+ --default-artifact-root $ARTIFACT_STORE_URI
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ boto3 # Still needed for interacting with some cloud storage, even if GCP
2
+ mlflow
3
+ psycopg2-binary
4
+ google-cloud-storage # For interacting with Google Cloud Storage
5
+ google-cloud-bigquery # If you're using BigQuery
6
+ fastapi # for first test
7
+ uvicorn