Spaces:
Paused
Paused
jedick
commited on
Commit
·
72d25de
1
Parent(s):
c16c507
Move entrypoint.sh out of docker/ directory
Browse files- Dockerfile +8 -7
- docker/entrypoint.sh → entrypoint.sh +0 -0
Dockerfile
CHANGED
|
@@ -5,19 +5,19 @@ FROM rocker/r-ver:latest
|
|
| 5 |
# Single RUN directive and two COPY directives
|
| 6 |
# Pre-RUN COPY for relatively stable files, post-RUN COPY for app files
|
| 7 |
# Avoid other directives like USER and ENV
|
| 8 |
-
#
|
| 9 |
# Considerations for remote development (HF Spaces Dev Mode)
|
| 10 |
# Dev Mode requires useradd, chown and USER
|
| 11 |
# Use CMD instead of ENTRYPOINT
|
| 12 |
|
| 13 |
# Set working directory and copy non-app files
|
| 14 |
WORKDIR /app
|
| 15 |
-
COPY requirements.txt
|
| 16 |
|
| 17 |
# Install Python and system tools
|
| 18 |
# Create and activate virtual environment for installing packages
|
| 19 |
# Install required Python and R packages
|
| 20 |
-
#
|
| 21 |
# Add user with uid=1000 and chown /app directory for HF Spaces Dev Mode
|
| 22 |
RUN apt-get update && \
|
| 23 |
apt-get install -y python3 python3-pip python3-venv screen vim git && \
|
|
@@ -27,17 +27,18 @@ RUN apt-get update && \
|
|
| 27 |
export PATH="/opt/venv/bin:$PATH" && \
|
| 28 |
pip --no-cache-dir install -r requirements.txt && \
|
| 29 |
R -q -e 'install.packages(c("ellmer", "mcptools", "readr", "ggplot2", "tidyverse"))' && \
|
| 30 |
-
|
|
|
|
| 31 |
useradd -m -u 1000 user && \
|
| 32 |
chown -R user /app
|
| 33 |
|
| 34 |
# Copy app files with user permissions
|
| 35 |
-
# NOTE:
|
| 36 |
-
#
|
| 37 |
COPY --chown=user . /app
|
| 38 |
|
| 39 |
# Set the user for Dev Mode
|
| 40 |
USER user
|
| 41 |
|
| 42 |
# Set default command (executable file in WORKDIR)
|
| 43 |
-
CMD [ "/app/
|
|
|
|
| 5 |
# Single RUN directive and two COPY directives
|
| 6 |
# Pre-RUN COPY for relatively stable files, post-RUN COPY for app files
|
| 7 |
# Avoid other directives like USER and ENV
|
| 8 |
+
# startup.sh activates the virtual environment for running the app
|
| 9 |
# Considerations for remote development (HF Spaces Dev Mode)
|
| 10 |
# Dev Mode requires useradd, chown and USER
|
| 11 |
# Use CMD instead of ENTRYPOINT
|
| 12 |
|
| 13 |
# Set working directory and copy non-app files
|
| 14 |
WORKDIR /app
|
| 15 |
+
COPY requirements.txt entrypoint.sh .
|
| 16 |
|
| 17 |
# Install Python and system tools
|
| 18 |
# Create and activate virtual environment for installing packages
|
| 19 |
# Install required Python and R packages
|
| 20 |
+
# Rename startup script and make it executable
|
| 21 |
# Add user with uid=1000 and chown /app directory for HF Spaces Dev Mode
|
| 22 |
RUN apt-get update && \
|
| 23 |
apt-get install -y python3 python3-pip python3-venv screen vim git && \
|
|
|
|
| 27 |
export PATH="/opt/venv/bin:$PATH" && \
|
| 28 |
pip --no-cache-dir install -r requirements.txt && \
|
| 29 |
R -q -e 'install.packages(c("ellmer", "mcptools", "readr", "ggplot2", "tidyverse"))' && \
|
| 30 |
+
cp entrypoint.sh startup.sh && \
|
| 31 |
+
chmod +x startup.sh && \
|
| 32 |
useradd -m -u 1000 user && \
|
| 33 |
chown -R user /app
|
| 34 |
|
| 35 |
# Copy app files with user permissions
|
| 36 |
+
# NOTE: This overwrites all copied files, rendering them non-executable. That is why we
|
| 37 |
+
# created an executable file with a different name (startup.sh) that is not overwritten here.
|
| 38 |
COPY --chown=user . /app
|
| 39 |
|
| 40 |
# Set the user for Dev Mode
|
| 41 |
USER user
|
| 42 |
|
| 43 |
# Set default command (executable file in WORKDIR)
|
| 44 |
+
CMD [ "/app/startup.sh" ]
|
docker/entrypoint.sh → entrypoint.sh
RENAMED
|
File without changes
|