11# Layer 1: Build the virtual environment
2- FROM ghcr.io/lambda-feedback/evaluation-function-base/python :3.11 AS builder
2+ FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer :3.11 AS builder
33
44RUN pip install poetry==1.8.3
55
@@ -15,13 +15,13 @@ RUN --mount=type=cache,target=$POETRY_CACHE_DIR \
1515 poetry install --without dev --no-root
1616
1717# Layer 2: Download NLTK models
18- FROM ghcr.io/lambda-feedback/evaluation-function-base/python :3.11 AS models
18+ FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer :3.11 AS models
1919
2020ENV NLTK_DATA=/usr/share/nltk_data
2121
22- ENV MODEL_PATH=/app/evaluation_function /models
22+ ENV MODEL_PATH=/app/app /models
2323
24- RUN apt-get update && apt-get install -y --no-install-recommends \
24+ RUN yum install -y \
2525 wget \
2626 unzip
2727
@@ -31,17 +31,17 @@ RUN ./scripts/download_models.sh
3131RUN ./scripts/download_nltk.sh
3232
3333# Layer 3: Final image
34- FROM ghcr.io/lambda-feedback/evaluation-function-base/python :3.11
34+ FROM ghcr.io/lambda-feedback/baseevalutionfunctionlayer :3.11
3535
3636ENV VIRTUAL_ENV=/app/.venv \
3737 PATH="/app/.venv/bin:$PATH"
3838
3939ENV NLTK_DATA=/usr/share/nltk_data
4040
41- ENV MODEL_PATH=/app/evaluation_function /models
41+ ENV MODEL_PATH=/app/app /models
4242
4343# Copy the evaluation function to the app directory
44- COPY ./evaluation_function ./evaluation_function
44+ COPY ./evaluation_function ./app
4545
4646# Precompile python files for faster startup
4747RUN python -m compileall -q .
@@ -50,34 +50,9 @@ COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV}
5050COPY --from=models ${NLTK_DATA} ${NLTK_DATA}
5151COPY --from=models ${MODEL_PATH} ${MODEL_PATH}
5252
53- # ----- For Linux development instead of Layer 2 NLTK downloads
54- # # Warnings: those commands sometimes download corrupted zips, so it is better to wget each package from the main site
55- # RUN python -m nltk.downloader wordnet
56- # RUN python -m nltk.downloader word2vec_sample
57- # RUN python -m nltk.downloader brown
58- # RUN python -m nltk.downloader stopwords
59- # RUN python -m nltk.downloader punkt
60- # RUN python -m nltk.downloader punkt_tab
53+ # Set permissions so files and directories can be accessed on AWS
54+ RUN chmod 644 $(find ./app/ -type f)
55+ RUN chmod 755 $(find ./app/ -type d)
6156
62- # Worker process start timeout to allow shimmy to start considering all downloads
63- ENV FUNCTION_WORKER_SEND_TIMEOUT="600s"
64-
65- # Worker process stop timeout to allow shimmy to stop the container
66- ENV FUNCTION_WORKER_STOP_TIMEOUT="300s"
67-
68- ENV EVAL_RPC_TRANSPORT="ipc"
69-
70- # Command to start the evaluation function with
71- ENV FUNCTION_COMMAND="python"
72-
73- # Args to start the evaluation function with
74- ENV FUNCTION_ARGS="-m,evaluation_function.main"
75-
76- # The transport to use for the RPC server
77- ENV FUNCTION_RPC_TRANSPORT="ipc"
78-
79- ENV LOG_LEVEL="debug"
80-
81- # ------- FOR DEBIAN
82- # Keep the container running
83- # CMD ["tail", "-f", "/dev/null"]
57+ # The entrypoint for AWS is to invoke the handler function within the app package
58+ CMD [ "/app/app.handler" ]
0 commit comments