Last active
July 2, 2021 02:40
-
-
Save couragecowardlydog/3f0d716da6696204c9216c1f07d4e7b9 to your computer and use it in GitHub Desktop.
Dockerfile : Stop writing your Dockerfile
This file contains hidden or 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
# The tag here should match the Meteor version of your app, per .meteor/release | |
FROM geoffreybooth/meteor-base | |
# Copy app package.json and package-lock.json into container | |
COPY ./app/package*.json $APP_SOURCE_FOLDER/ | |
RUN bash $SCRIPTS_FOLDER/build-app-npm-dependencies.sh | |
# Copy app source into container | |
COPY ./app $APP_SOURCE_FOLDER/ | |
RUN bash $SCRIPTS_FOLDER/build-meteor-bundle.sh | |
# Use the specific version of Node expected by your Meteor release, per https://docs.meteor.com/changelog.html; this is expected for Meteor 2.2 | |
FROM node:14.17.1-alphine | |
ENV APP_BUNDLE_FOLDER /opt/bundle | |
ENV SCRIPTS_FOLDER /docker | |
# 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 \ | |
g++ \ | |
make \ | |
python | |
# Copy in entrypoint | |
COPY --from=0 $SCRIPTS_FOLDER $SCRIPTS_FOLDER/ | |
# Copy in app bundle | |
COPY --from=0 $APP_BUNDLE_FOLDER/bundle $APP_BUNDLE_FOLDER/bundle/ | |
RUN bash $SCRIPTS_FOLDER/build-meteor-npm-dependencies.sh --build-from-source | |
# 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:12.22.1-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"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment