This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial code drop * Added readme and .travis.yml * Made docker org an env var. * added a deploy phase * Adjusted deploy phase
- Loading branch information
Showing
5 changed files
with
85 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
language: bash | ||
os: | ||
- linux | ||
services: | ||
- docker | ||
deploy: | ||
provider: script | ||
script: bash ./docker-build.sh |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM gcr.io/cloud-builders/docker | ||
RUN apt-get update && \ | ||
apt-get -y install sudo jq wget | ||
RUN wget https://github.com/appsody/appsody/releases/download/0.2.2/appsody_0.2.2_amd64.deb | ||
COPY setupAndRunExtract.sh . | ||
RUN apt install -f ./appsody_0.2.2_amd64.deb |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,20 @@ | ||
# appsody-docker | ||
A docker image with Appsody CLI installed. Useful for running Appsody in Tekton pipelines. | ||
# Appsody in Docker | ||
|
||
A builder for the `appsody/appsody-docker` Docker image, which is the `gcr.io/cloud-builders/docker` image with the Appsody CLI added to it. The image can be used within a build pipeline - such as a Tekton pipeline - to perform actions using the Appsody CLI. | ||
|
||
At present, the image is equipped with a script (`setupAndRunExtract.sh`) that runs the `appsody extract` command, after mounting the appropriate project source directory. The script assumes that the image is running within a Docker container in a Tekton pipeline. It discovers the `/workspace` mount point, and retrieves the host's directory corresponding to that mount. It then gives that mount point to the Appsody CLI in the `APPSODY_MOUNT_PROJECT` environment variable. This type of retrieval is necessary because the Appsody CLI runs in Docker within a Docker image. | ||
|
||
### Building the image | ||
This repo includes a `.travis.yml` file that builds and pushes the image to Docker Hub. However, if you prefer building the image manually, issue the following command: | ||
|
||
```sh | ||
docker build -t appsody-docker -f Dockerfile . | ||
``` | ||
|
||
### Using the image | ||
An example of usage is provided by the [Appsody Tekton pipeline example](https://github.com/appsody/tekton-example). Check out the [Appsody build task](https://github.com/appsody/tekton-example/blob/master/appsody-build-task.yaml) manifest. | ||
|
||
In that context, the image runs the `appsody extract` command to retrieve the entire project tree from the Appsody stack image and the application source tree hosted on GitHub. | ||
|
||
This image could be modified to run additional `appsody` commands if necessary. | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
set -e | ||
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin | ||
docker build -t $DOCKER_ORG/appsody-docker . | ||
docker push $DOCKER_ORG/appsody-docker |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
set -e | ||
# inspecting the container to find the mounts | ||
containerid=`docker ps|grep appsody-docker|awk '{print $1}'` | ||
dockerinspect=`docker inspect ${containerid}` | ||
# checking the mounts to extract the workspace mount | ||
notdone=true | ||
found=false | ||
idx=0 | ||
while [ "$notdone" = true ]; do | ||
dest=`echo ${dockerinspect}|jq --argjson index $idx '.[] | .Mounts[$index].Destination '` | ||
echo $dest | ||
if [ "$dest" = "\"/workspace\"" ] ; then | ||
source=`echo ${dockerinspect}|jq --argjson index $idx '.[] | .Mounts[$index].Source '` | ||
found=true | ||
notdone=false | ||
elif [ "$dest" == null ]; then | ||
notdone=false | ||
fi | ||
idx=$[$idx+1] | ||
|
||
done | ||
if [ ! "$found" = true ] ; then | ||
echo Could not find a workspace mount - something is wrong | ||
exit 1 | ||
else | ||
echo Source mount is ${source} | ||
# Removing the quotes | ||
source="${source%\"}" | ||
source="${source#\"}" | ||
fi | ||
# Appending appsody-source | ||
postfix="/appsody-source" | ||
source=$source$postfix | ||
export APPSODY_MOUNT_PROJECT=${source} | ||
echo APPSODY_MOUNT_PROJECT=${APPSODY_MOUNT_PROJECT} | ||
# Create the /extracted sub-dir | ||
mkdir /workspace/extracted | ||
# Run appsody extract -v from the source directory | ||
cd /workspace/appsody-source | ||
ls -latr | ||
appsody extract -v | ||
# Copy the extracted contents to /workspace/extracted | ||
cp -rf /builder/home/.appsody/extract/appsody-source/* /workspace/extracted/ | ||
ls -latr /workspace/extracted | ||
|