Richard Guo
commited on
Commit
·
46270d0
1
Parent(s):
78bd78c
permission and secret handling
Browse files- Dockerfile +19 -2
- main.py +1 -0
Dockerfile
CHANGED
|
@@ -4,15 +4,32 @@
|
|
| 4 |
# Use an official Python runtime as a parent image
|
| 5 |
FROM python:3.9
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
# Set the working directory in the container to /app
|
| 8 |
-
WORKDIR /app
|
| 9 |
|
| 10 |
# Add the current directory contents into the container at /app
|
| 11 |
-
ADD . /app
|
| 12 |
|
| 13 |
# Install any needed packages specified in requirements.txt
|
| 14 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
# Make port 7860 available to the world outside this container
|
| 17 |
EXPOSE 7860
|
| 18 |
|
|
|
|
| 4 |
# Use an official Python runtime as a parent image
|
| 5 |
FROM python:3.9
|
| 6 |
|
| 7 |
+
# Set up a new user named "user" with user ID 1000
|
| 8 |
+
RUN useradd -m -u 1000 user
|
| 9 |
+
|
| 10 |
+
# Switch to the "user" user
|
| 11 |
+
USER user
|
| 12 |
+
|
| 13 |
+
# Set home to the user's home directory
|
| 14 |
+
ENV HOME=/home/user \
|
| 15 |
+
PATH=/home/user/.local/bin:$PATH
|
| 16 |
+
|
| 17 |
# Set the working directory in the container to /app
|
| 18 |
+
WORKDIR $HOME/app
|
| 19 |
|
| 20 |
# Add the current directory contents into the container at /app
|
| 21 |
+
ADD . $HOME/app
|
| 22 |
|
| 23 |
# Install any needed packages specified in requirements.txt
|
| 24 |
RUN pip install --no-cache-dir -r requirements.txt
|
| 25 |
|
| 26 |
+
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 27 |
+
COPY --chown=user . $HOME/app
|
| 28 |
+
|
| 29 |
+
# Expose the secret NOMIC_API_KEY at buildtime and use its value
|
| 30 |
+
RUN --mount=type=secret,id=NOMIC_API_KEY,mode=0444,required=true \
|
| 31 |
+
nomic login $(cat /run/secrets/NOMIC_API_KEY)
|
| 32 |
+
|
| 33 |
# Make port 7860 available to the world outside this container
|
| 34 |
EXPOSE 7860
|
| 35 |
|
main.py
CHANGED
|
@@ -4,6 +4,7 @@ from fastapi.templating import Jinja2Templates
|
|
| 4 |
#from pydantic import BaseModel
|
| 5 |
|
| 6 |
from uuid import uuid4
|
|
|
|
| 7 |
import asyncio
|
| 8 |
|
| 9 |
from build_map import load_dataset_and_metadata, upload_dataset_to_atlas
|
|
|
|
| 4 |
#from pydantic import BaseModel
|
| 5 |
|
| 6 |
from uuid import uuid4
|
| 7 |
+
import time
|
| 8 |
import asyncio
|
| 9 |
|
| 10 |
from build_map import load_dataset_and_metadata, upload_dataset_to_atlas
|