circulartext commited on
Commit
23aa172
·
1 Parent(s): 1130934

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +17 -18
Dockerfile CHANGED
@@ -21,34 +21,33 @@ RUN if id "$USER_ID" >/dev/null 2>&1; then \
21
  # Set appropriate permissions for the application directory
22
  RUN chown -R user:user /app && chmod -R 755 /app
23
 
24
- # Switch to the user for improved security
25
- USER user
26
-
27
  # Install build tools
28
- RUN apt-get update && apt-get install -y build-essential
 
 
 
29
 
30
- # Download and compile su-exec
31
- RUN wget -O su-exec.c 'https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c' && \
32
- gcc -o su-exec su-exec.c
33
 
34
- # Copy su-exec to /usr/sbin
35
- RUN cp su-exec /usr/sbin
36
 
37
- # Remove unnecessary build tools
38
- RUN apt-get purge -y build-essential && apt-get autoremove -y
39
 
40
  # Final image
41
  FROM base
42
 
43
- # Copy entrypoint.sh to /app
44
- COPY entrypoint.sh /app/entrypoint.sh
45
-
46
- # Change permissions using su-exec
47
- RUN su-exec user chmod +x /app/entrypoint.sh
48
 
49
  # Set the entrypoint script as executable
50
- ENTRYPOINT ["/app/entrypoint.sh"]
 
 
 
 
51
 
52
  # Default command to run if the user doesn't provide a command
53
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]
54
-
 
21
  # Set appropriate permissions for the application directory
22
  RUN chown -R user:user /app && chmod -R 755 /app
23
 
 
 
 
24
  # Install build tools
25
+ RUN mkdir -p /var/lib/apt/lists/partial && \
26
+ chmod 744 /var/lib/apt/lists && \
27
+ chmod 755 /var/lib/apt/lists/partial && \
28
+ apt-get update && apt-get install -y build-essential
29
 
30
+ # Switch to the user for improved security
31
+ USER user
 
32
 
33
+ # Intermediate image with additional packages
34
+ FROM debian:bullseye-slim as packages
35
 
36
+ # Install gosu using apt-get
37
+ RUN apt-get update && apt-get install -y gosu && rm -rf /var/lib/apt/lists/*
38
 
39
  # Final image
40
  FROM base
41
 
42
+ # Copy gosu from the packages image
43
+ COPY --from=packages /usr/sbin/gosu /usr/sbin/gosu
 
 
 
44
 
45
  # Set the entrypoint script as executable
46
+ COPY entrypoint.sh /usr/local/bin/entrypoint.sh
47
+ RUN chmod +x /usr/local/bin/entrypoint.sh
48
+
49
+ # Define the entrypoint script to handle user creation and application startup
50
+ ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
51
 
52
  # Default command to run if the user doesn't provide a command
53
  CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860", "--reload"]