seanpedrickcase commited on
Commit
7c7fd7c
1 Parent(s): 7f5a542

Updated Dockerfile and entrypoint file to hopefully deal correctly with APP_MODE environment variable

Browse files
Files changed (2) hide show
  1. Dockerfile +7 -8
  2. entrypoint.sh +2 -0
Dockerfile CHANGED
@@ -28,9 +28,15 @@ COPY entrypoint.sh .
28
  # Stage 2: Final runtime image
29
  FROM public.ecr.aws/docker/library/python:3.11.9-slim-bookworm
30
 
31
- # Define a build argument for the mode (gradio or lambda)
32
  ARG APP_MODE=gradio
33
 
 
 
 
 
 
 
34
  # Install system dependencies
35
  RUN apt-get update \
36
  && apt-get install -y \
@@ -53,13 +59,6 @@ RUN mkdir -p /home/user/app/output \
53
  # Copy installed packages from builder stage
54
  COPY --from=builder /install /usr/local/lib/python3.11/site-packages/
55
 
56
- # Use a conditional entrypoint based on the APP_MODE argument (deprecated, now created beforehand in folder)
57
- # RUN if [ "$APP_MODE" = "lambda" ]; then \
58
- # echo '#!/bin/sh\nexec python -m awslambdaric' > /entrypoint.sh; \
59
- # else \
60
- # echo '#!/bin/sh\nexec python app.py' > /entrypoint.sh; \
61
- # fi && chmod +x /entrypoint.sh
62
-
63
  # Entrypoint helps to switch between Gradio and Lambda mode
64
  COPY entrypoint.sh /entrypoint.sh
65
 
 
28
  # Stage 2: Final runtime image
29
  FROM public.ecr.aws/docker/library/python:3.11.9-slim-bookworm
30
 
31
+ # Define a build argument with a default value
32
  ARG APP_MODE=gradio
33
 
34
+ # Echo the APP_MODE during the build to confirm its value
35
+ RUN echo "APP_MODE is set to: ${APP_MODE}"
36
+
37
+ # Set APP_MODE as an environment variable for runtime
38
+ ENV APP_MODE=${APP_MODE}
39
+
40
  # Install system dependencies
41
  RUN apt-get update \
42
  && apt-get install -y \
 
59
  # Copy installed packages from builder stage
60
  COPY --from=builder /install /usr/local/lib/python3.11/site-packages/
61
 
 
 
 
 
 
 
 
62
  # Entrypoint helps to switch between Gradio and Lambda mode
63
  COPY entrypoint.sh /entrypoint.sh
64
 
entrypoint.sh CHANGED
@@ -1,5 +1,7 @@
1
  #!/bin/sh
2
 
 
 
3
  if [ "$APP_MODE" = "lambda" ]; then
4
  echo "Starting in Lambda mode..."
5
  exec python -m awslambdaric "$@"
 
1
  #!/bin/sh
2
 
3
+ echo "Starting in APP_MODE: $APP_MODE"
4
+
5
  if [ "$APP_MODE" = "lambda" ]; then
6
  echo "Starting in Lambda mode..."
7
  exec python -m awslambdaric "$@"