11# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
22# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
33
4- # This Dockerfile is for building the final production image. It's based on ghcr.io/oracle/macaron-base.
5- # For the build, two files will be copied into the image:
4+ # This Dockerfile is for building the final production image. It's based on ghcr.io/oracle/macaron-base and ghcr.io/oracle/maracon-deps .
5+ # For the build, three files will be copied into the image:
66# - Macaron wheel file (its path must be provided to the build argument WHEEL_PATH)
7+ # - Macaron dependency files, copied from the macaron-deps image.
78# - user.sh for the entrypoint of the final image.
89# For example, using Docker, we could build the image using:
910# docker build --build-arg WHEEL_PATH=<path_to_wheel> -t ghcr.io/oracle/macaron -f docker/Dockerfile.final ./
1011# Note that the local machine must login to ghcr.io so that Docker could pull the ghcr.io/oracle/macaron-base
1112# image for this build.
1213
14+ FROM ghcr.io/oracle/macaron-deps:latest@sha256:99526baf6596c4c3f24e4caa2b59afaf7f7c26d633ad3113ca24ba43dfad3f0f as deps_stage
15+
1316FROM ghcr.io/oracle/macaron-base:latest@sha256:79b3b8b03cb9b6a124c6450f4baa58f96f83ee9e37f572c88a97597b35c7bc51
1417
1518ENV HOME="/home/macaron"
@@ -34,11 +37,17 @@ ARG WHEEL_PATH
3437# the warning of not having correct ownership of /home/macaron is not raised.
3538USER macaron:macaron
3639COPY --chown=macaron:macaron $WHEEL_PATH $HOME/dist/
40+ # Currently, the only dependency stored in the minimal image is the wheel for Semgrep, which we copy here. Since the
41+ # Macaron project dependencies lists Semgrep as a python dependency, we uninstall it first before using our wheel here
42+ # to install a trusted built-from-source version.
43+ COPY --chown=macaron:macaron --from=deps_stage /semgrep-*manylinux*.whl $HOME/dist/
3744RUN : \
3845 && python3 -m venv $HOME/.venv \
3946 && . .venv/bin/activate \
4047 && pip install --no-compile --no-cache-dir --upgrade pip setuptools \
4148 && find $HOME/dist -depth \( -type f \( -name "macaron-*.whl" \) \) -exec pip install --no-compile --no-cache-dir '{}' \; \
49+ && pip uninstall semgrep \
50+ && find $HOME/dist -depth \( -type f \( -name "semgrep-*.whl" \) \) -exec pip install --no-compile --no-cache-dir '{}' \; \
4251 && rm -rf $HOME/dist \
4352 && deactivate
4453
0 commit comments