Public | Automated Build

Last pushed: 2 years ago
Short Description
CleanOffer dev environment
Full Description

CleanOffer Build Environment

Build environment for CleanOffer. To run maven commands, create a container with:

  • The source code should be copied or mounted to the container at
    /usr/src/cleanoffer.

  • Your cloudbees credentials should be given in the environment variables
    CLOUDBEES_USER and CLOUDBEES_PASSWORD

For example the following command will run mvn install on the code located
in ~/code/cleanoffer directory on the host.

docker run --rm \
  -v ~/code/cleanoffer:/usr/src/cleanoffer \
  -e "CLOUDBEES_USER=<username>" \
  -e "CLOUDBEES_PASSWORD=<password>" \
  cleanoffer/cleanoffer-build \
  mvn clean install

Tips

Use a data container for the maven repository

Since the container created by the above command is short lived, the
local maven repository is lost when the container is destroyed. The next
time a build is run, all of the jars must be downloaded again. To preserve
the local repository, simply create a container to cache the data.

Create a container that exports a volume for the maven repository

docker create \
  -v /root/.m2/repository \
  --name="cleanoffer-maven-repo" \
  busybox \
  /bin/true

busybox is a good image choice since it is very small.

Import the volume by adding the --volumes-from option to your run command

docker run \
  --rm \
  -v ~/code/cleanoffer:/usr/src/cleanoffer \
  -e "CLOUDBEES_USER=<username>" \
  -e "CLOUDBEES_PASSWORD=<password>" \
  --volumes-from=cleanoffer-maven-repo \
  cleanoffer/cleanoffer-build \
  mvn clean install

The cleanoffer-maven-repo container will persist in a stopped state until
it is deleted, but it's exported volume can be used even though the container
isn't running.

Delete the data container when you no longer need the cached data

Once created the container can be used until it is no longer needed. Use
docker rm to delete the container and free up the disk space once you no
longer need it. Use the -v to delete the volume, otherwise the volume will
not be deleted when the container is deleted.

docker rm -v cleanoffer-maven-repo
Docker Pull Command
Owner
cleanoffer
Source Repository

Comments (0)