From cf35380347d4ea0f5f0b81d19217d1bc6c3d4dd3 Mon Sep 17 00:00:00 2001 From: Mikus G Date: Thu, 7 Nov 2024 22:02:26 +0200 Subject: [PATCH] Update Dockerfile --- Dockerfile | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/Dockerfile b/Dockerfile index 2c198531..efc6627b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,6 @@ # The tag here should match the Meteor version of your app, per .meteor/release FROM geoffreybooth/meteor-base:2.16 -# Ensure Python and build tools are available (for cross-platform build) -RUN apt-get update && apt-get install -y python3 build-essential && \ - meteor npm config set python python3 - # Copy app package.json and package-lock.json into container COPY ./app/package*.json $APP_SOURCE_FOLDER/ @@ -23,13 +19,12 @@ FROM node:14.21.0-alpine ENV APP_BUNDLE_FOLDER=/opt/bundle ENV SCRIPTS_FOLDER=/docker -# Runtime dependencies; if your dependencies need compilation (native modules such as bcrypt) or you are using Meteor <1.8.1, use app-with-native-dependencies.dockerfile instead +# Install OS build dependencies, which stay with this intermediate image but don’t become part of the final published image RUN apk --no-cache add \ - bash \ - ca-certificates \ - python3 \ - build-base && \ - npm config set python python3 + bash \ + g++ \ + make \ + python3 # Copy in entrypoint COPY --from=0 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/ @@ -37,14 +32,27 @@ COPY --from=0 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/ # Copy in app bundle COPY --from=0 $APP_BUNDLE_FOLDER/bundle $APP_BUNDLE_FOLDER/bundle/ -# COPY ./app/private/jsons /opt/meteor/dist/bundle/private/jsons -# COPY ./app/private/jsons $APP_BUNDLE_FOLDER/bundle/private/jsons -# COPY ./app/private/jsons $APP_BUNDLE_FOLDER/bundle/programs/server/assets/app/jsons +RUN bash $SCRIPTS_FOLDER/build-meteor-npm-dependencies.sh --build-from-source -RUN bash $SCRIPTS_FOLDER/build-meteor-npm-dependencies.sh +# Start another Docker stage, so that the final image doesn’t contain the layer with the build dependencies +# See previous FROM line; this must match +FROM node:14.21.0-alpine + +ENV APP_BUNDLE_FOLDER /opt/bundle +ENV SCRIPTS_FOLDER /docker + +# Install OS runtime dependencies +RUN apk --no-cache add \ + bash \ + ca-certificates + +# Copy in entrypoint with the built and installed dependencies from the previous image +COPY --from=1 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/ + +# Copy in app bundle with the built and installed dependencies from the previous image +COPY --from=1 $APP_BUNDLE_FOLDER/bundle $APP_BUNDLE_FOLDER/bundle/ # Start app ENTRYPOINT ["/docker/entrypoint.sh"] CMD ["node", "main.js"] -