Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --build-arg PRE_INSTALL_SCRIPT to improve build time #88

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea
.idea/**/tasks.xml
.idea/dictionaries

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ RUN chmod -R 750 $BUILD_SCRIPTS_DIR
ONBUILD ARG APT_GET_INSTALL
ONBUILD ENV APT_GET_INSTALL $APT_GET_INSTALL

ONBUILD ARG PRE_INSTALL_SCRIPT
ONBUILD ENV PRE_INSTALL_SCRIPT $PRE_INSTALL_SCRIPT

ONBUILD ARG NODE_VERSION
ONBUILD ENV NODE_VERSION ${NODE_VERSION:-8.9.0}

Expand All @@ -46,6 +49,10 @@ ONBUILD ENV INSTALL_GRAPHICSMAGICK $INSTALL_GRAPHICSMAGICK
ONBUILD ARG TOOL_NODE_FLAGS
ONBUILD ENV TOOL_NODE_FLAGS $TOOL_NODE_FLAGS

# optionally run scripts before launchpad installation to cache big dependencies in lower layer that don´t change often
ONBUILD COPY ./$PRE_INSTALL_SCRIPT $BUILD_SCRIPTS_DIR
ONBUILD RUN if [ "$PRE_INSTALL_SCRIPT" ]; then $BUILD_SCRIPTS_DIR/$PRE_INSTALL_SCRIPT; fi

# optionally custom apt dependencies at app build time
ONBUILD RUN if [ "$APT_GET_INSTALL" ]; then apt-get update && apt-get install -y $APT_GET_INSTALL; fi

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ If you prefer not to have a config file in your project, your other option is to
```sh
docker build \
--build-arg APT_GET_INSTALL="curl git wget" \
--build-arg PRE_INSTALL_SCRIPT="yourscript.sh" \
--build-arg INSTALL_MONGO=true \
--build-arg NODE_VERSION=8.9.0 \
-t myorg/myapp:latest .
Expand Down
7 changes: 7 additions & 0 deletions dev.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ RUN bash $BUILD_SCRIPTS_DIR/install-deps.sh && \
ONBUILD ARG APT_GET_INSTALL
ONBUILD ENV APT_GET_INSTALL $APT_GET_INSTALL

ONBUILD ARG PRE_INSTALL_SCRIPT
ONBUILD ENV PRE_INSTALL_SCRIPT $PRE_INSTALL_SCRIPT

ONBUILD ARG NODE_VERSION
ONBUILD ENV NODE_VERSION ${NODE_VERSION:-8.9.0}

Expand All @@ -45,6 +48,10 @@ ONBUILD ENV INSTALL_PHANTOMJS ${INSTALL_PHANTOMJS:-true}
ONBUILD ARG INSTALL_GRAPHICSMAGICK
ONBUILD ENV INSTALL_GRAPHICSMAGICK ${INSTALL_GRAPHICSMAGICK:-true}

# optionally run scripts before launchpad installation to cache big dependencies in lower layer that don´t change often
ONBUILD COPY ./$PRE_INSTALL_SCRIPT $BUILD_SCRIPTS_DIR
ONBUILD RUN if [ "$PRE_INSTALL_SCRIPT" ]; then $BUILD_SCRIPTS_DIR/$PRE_INSTALL_SCRIPT; fi

# optionally custom apt dependencies at app build time
ONBUILD RUN if [ "$APT_GET_INSTALL" ]; then apt-get update && apt-get install -y $APT_GET_INSTALL; fi

Expand Down