mirror of
https://github.com/openshift/openshift-docs.git
synced 2026-02-06 06:46:26 +01:00
59 lines
1.9 KiB
Plaintext
59 lines
1.9 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 may find it necessary to 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 in `BuildConfig`
|
|
* Providing explicitly using `oc start-build --env` (only for builds that are triggered manually)
|
|
|
|
//.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.
|