mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-05 12:46:18 +01:00
60 lines
2.0 KiB
Plaintext
60 lines
2.0 KiB
Plaintext
// Module included in the following assemblies:
|
|
//
|
|
//* builds/creating-build-inputs.adoc
|
|
|
|
[id="builds-using-external-artifacts_{context}"]
|
|
= External artifacts
|
|
|
|
It is not recommended to store binary files in a source repository. Therefore, you must define a build which pulls additional files, such as Java `.jar` dependencies, during the build process. How this is done depends on the build strategy you are using.
|
|
|
|
For a Source build strategy, you must put appropriate shell commands into the `assemble` script:
|
|
|
|
.`.s2i/bin/assemble` File
|
|
[source,terminal]
|
|
----
|
|
#!/bin/sh
|
|
APP_VERSION=1.0
|
|
wget http://repository.example.com/app/app-$APP_VERSION.jar -O app.jar
|
|
----
|
|
|
|
.`.s2i/bin/run` File
|
|
[source,terminal]
|
|
----
|
|
#!/bin/sh
|
|
exec java -jar app.jar
|
|
----
|
|
|
|
ifndef::openshift-online[]
|
|
For a Docker build strategy, you must modify the Dockerfile and invoke
|
|
shell commands with the link:https://docs.docker.com/engine/reference/builder/#run[`RUN` instruction]:
|
|
|
|
.Excerpt of Dockerfile
|
|
[source,terminal]
|
|
----
|
|
FROM jboss/base-jdk:8
|
|
|
|
ENV APP_VERSION 1.0
|
|
RUN wget http://repository.example.com/app/app-$APP_VERSION.jar -O app.jar
|
|
|
|
EXPOSE 8080
|
|
CMD [ "java", "-jar", "app.jar" ]
|
|
----
|
|
endif::[]
|
|
|
|
In practice, you may want to use an environment variable for the file location so that the specific file to be downloaded can be customized using an environment variable defined on the `BuildConfig`, rather than updating the
|
|
ifndef::openshift-online[]
|
|
Dockerfile or
|
|
endif::[]
|
|
`assemble` script.
|
|
|
|
You can choose between different methods of defining environment variables:
|
|
|
|
* Using the `.s2i/environment` file (only for a `Source` build strategy)
|
|
* Setting the variables in the `BuildConfig` object
|
|
* Providing the variables explicitly using the `oc start-build --env` command (only for builds that are triggered manually)
|
|
|
|
//[role="_additional-resources"]
|
|
//.Additional resources
|
|
//* For more information on how to control which *_assemble_* and *_run_* script is
|
|
//used by a Source build, see Overriding builder image scripts.
|