Spaces:
Running
Running
更新 Dockerfile,启用用户创建和切换,设置用户环境变量和工作目录
Browse files- Dockerfile +6 -6
Dockerfile
CHANGED
|
@@ -15,18 +15,18 @@ RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt
|
|
| 15 |
EXPOSE 7860
|
| 16 |
|
| 17 |
# Set up a new user named "user" with user ID 1000
|
| 18 |
-
|
| 19 |
# Switch to the "user" user
|
| 20 |
-
|
| 21 |
# Set home to the user's home directory
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
# Set the working directory to the user's home directory
|
| 26 |
-
|
| 27 |
|
| 28 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 29 |
-
|
| 30 |
|
| 31 |
|
| 32 |
# Get secret EXAMPLE and output it to /test at buildtime
|
|
|
|
| 15 |
EXPOSE 7860
|
| 16 |
|
| 17 |
# Set up a new user named "user" with user ID 1000
|
| 18 |
+
RUN useradd -m -u 1000 user
|
| 19 |
# Switch to the "user" user
|
| 20 |
+
USER user
|
| 21 |
# Set home to the user's home directory
|
| 22 |
+
ENV HOME=/home/user \
|
| 23 |
+
PATH=/home/user/.local/bin:$PATH
|
| 24 |
|
| 25 |
# Set the working directory to the user's home directory
|
| 26 |
+
WORKDIR $HOME/app
|
| 27 |
|
| 28 |
# Copy the current directory contents into the container at $HOME/app setting the owner to the user
|
| 29 |
+
COPY --chown=user . $HOME/app
|
| 30 |
|
| 31 |
|
| 32 |
# Get secret EXAMPLE and output it to /test at buildtime
|