1
1
# Copyright (c) 2022 - 2023, Oracle and/or its affiliates. All rights reserved.
2
2
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/.
3
3
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:
6
6
# - Macaron wheel file (its path must be provided to the build argument WHEEL_PATH)
7
+ # - Macaron dependency files, copied from the macaron-deps image.
7
8
# - user.sh for the entrypoint of the final image.
8
9
# For example, using Docker, we could build the image using:
9
10
# docker build --build-arg WHEEL_PATH=<path_to_wheel> -t ghcr.io/oracle/macaron -f docker/Dockerfile.final ./
10
11
# Note that the local machine must login to ghcr.io so that Docker could pull the ghcr.io/oracle/macaron-base
11
12
# image for this build.
12
13
14
+ FROM ghcr.io/oracle/macaron-deps:latest@sha256:99526baf6596c4c3f24e4caa2b59afaf7f7c26d633ad3113ca24ba43dfad3f0f as deps_stage
15
+
13
16
FROM ghcr.io/oracle/macaron-base:latest@sha256:79b3b8b03cb9b6a124c6450f4baa58f96f83ee9e37f572c88a97597b35c7bc51
14
17
15
18
ENV HOME="/home/macaron"
@@ -34,11 +37,17 @@ ARG WHEEL_PATH
34
37
# the warning of not having correct ownership of /home/macaron is not raised.
35
38
USER macaron:macaron
36
39
COPY --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/
37
44
RUN : \
38
45
&& python3 -m venv $HOME/.venv \
39
46
&& . .venv/bin/activate \
40
47
&& pip install --no-compile --no-cache-dir --upgrade pip setuptools \
41
48
&& 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 '{}' \; \
42
51
&& rm -rf $HOME/dist \
43
52
&& deactivate
44
53
0 commit comments