generated from NOAA-OWP/owp-open-source-project-template
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update docker build for raster processing pipeline (#1049)
Update raster processing image to use a new conda-managed environment. Refs #1029
- Loading branch information
Showing
5 changed files
with
264 additions
and
37 deletions.
There are no files selected for viewing
55 changes: 40 additions & 15 deletions
55
Core/LAMBDA/viz_functions/image_based/viz_raster_processing/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,45 @@ | ||
FROM public.ecr.aws/lambda/python:3.9 | ||
FROM mambaorg/micromamba AS micromamba | ||
|
||
# Create conda environment for hydrovis | ||
RUN --mount=type=bind,source=conda-linux-64.lock,target=/tmp/conda.lock \ | ||
micromamba install -y --file /tmp/conda.lock && \ | ||
micromamba clean -afy | ||
|
||
# Clean out unnecessary files to reduce image size | ||
RUN find /opt/conda -regex '^.*\(__pycache__\|\.py[co]\)$' -delete && \ | ||
find /opt/conda -follow -type f -name '*.a' -delete | ||
RUN rm -rf /opt/conda/man /opt/conda/share/man /opt/conda/share/doc && \ | ||
rm -rf /opt/conda/include && \ | ||
rm -rf /opt/conda/share/bash-completion && \ | ||
rm -rf /opt/conda/share/info && \ | ||
rm -rf /opt/conda/share/examples && \ | ||
rm -rf /opt/conda/conda-meta | ||
|
||
# Copy function code | ||
COPY lambda_function.py ${LAMBDA_TASK_ROOT} | ||
ADD products "${LAMBDA_TASK_ROOT}/products" | ||
COPY serverless.yml ${LAMBDA_TASK_ROOT} | ||
COPY viz_classes.py ${LAMBDA_TASK_ROOT} | ||
COPY viz_lambda_shared_funcs.py ${LAMBDA_TASK_ROOT} | ||
|
||
# Install the function's dependencies using file requirements.txt | ||
# from your project folder. | ||
FROM public.ecr.aws/amazonlinux/amazonlinux:2023-minimal AS alinux | ||
|
||
COPY requirements.txt . | ||
RUN pip3 install -r requirements.txt --target "${LAMBDA_TASK_ROOT}" | ||
ENV MAMBA_ROOT_PREFIX="/opt/conda" | ||
ENV MAMBA_EXE="/bin/micromamba" | ||
# Prevent Python from writing bytecode files | ||
ENV PYTHONDONTWRITEBYTECODE=1 | ||
# Prevent python from buffering stdout | ||
ENV PYTHONUNBUFFERED=1 | ||
COPY --from=micromamba --chown=root "$MAMBA_EXE" "$MAMBA_EXE" | ||
COPY --from=micromamba --chown=root /opt/conda /opt/conda | ||
COPY --from=micromamba --chown=root /usr/local/bin/_*.sh /usr/local/bin/ | ||
|
||
WORKDIR /home/code | ||
|
||
# Copy function code | ||
COPY products/ ./products/ | ||
COPY lambda_function.py \ | ||
viz_classes.py \ | ||
viz_lambda_shared_funcs.py \ | ||
./ | ||
|
||
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile) | ||
CMD [ "lambda_function.lambda_handler" ] | ||
SHELL ["/usr/local/bin/_dockerfile_shell.sh"] | ||
|
||
# Removes severity vulnerabilities | ||
RUN yum -y update | ||
ENTRYPOINT [ "/usr/local/bin/_entrypoint.sh" ] | ||
CMD [ \ | ||
"python", "-m", "awslambdaric", "lambda_function.lambda_handler" \ | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.