Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #512 from chris-crone/readme-20190417
Browse files Browse the repository at this point in the history
Rework examples and top level README
  • Loading branch information
chris-crone committed Apr 18, 2019
2 parents 29aa651 + 59c5ba9 commit dbe0367
Show file tree
Hide file tree
Showing 38 changed files with 515 additions and 961 deletions.
320 changes: 177 additions & 143 deletions README.md

Large diffs are not rendered by default.

19 changes: 4 additions & 15 deletions e2e/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package e2e
import (
"os"
"path/filepath"
"strings"
"testing"

"gotest.tools/assert"
Expand All @@ -15,22 +14,12 @@ func TestExamplesAreValid(t *testing.T) {
defer cleanup()

err := filepath.Walk("../examples", func(p string, info os.FileInfo, err error) error {
appPath := filepath.Join(p, filepath.Base(p)+".dockerapp")
_, statErr := os.Stat(appPath)
switch {
case strings.HasSuffix(p, "examples"):
return nil
case strings.HasSuffix(p, ".resources"):
return filepath.SkipDir
case !info.IsDir():
return nil
case os.IsNotExist(statErr):
return nil
default:
cmd.Command = dockerCli.Command("app", "validate", appPath)
if filepath.Ext(p) == ".dockerapp" {
t.Log("Validate example: " + p)
cmd.Command = dockerCli.Command("app", "validate", p)
icmd.RunCmd(cmd).Assert(t, icmd.Success)
return filepath.SkipDir
}
return nil
})
assert.NilError(t, err)
}
Binary file removed examples/.resources/cats-or-dogs.png
Binary file not shown.
Binary file removed examples/.resources/hello-world.png
Binary file not shown.
Binary file removed examples/.resources/wordpress.png
Binary file not shown.
33 changes: 14 additions & 19 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
## Examples

This folder contains several examples of applications built using `docker-app`, from a simple `hello-world` application to more complex, multi-service applications.
This folder contains several examples of applications built using Docker
Application, from a simple `hello-world` application to more complex,
multi-service applications.

### Hello world application: [hello world](hello-world)
### [Hello world!](hello-world)

To learn how to create a simple app that displays a given text.
Learn how the basics of how to write a simple Docker Application.

![Hello world app screenshot](.resources/hello-world.png "Hello world app screenshot")
### [Convert an existing Compose file](voting-app)

### Voting application: [voting-app](voting-app)
Learn how to create a Docker Application from an existing Compose file using the
Docker voting app from [Docker samples](https://github.com/dockersamples).

To learn how to create the Docker voting app from [Docker samples](https://github.com/dockersamples).
### [Docker Application CNAB generation](cnab-simple)

![Voting app screenshot](.resources/cats-or-dogs.png "Voting app screenshot")
Create a [CNAB](https://cnab.io) `bundle.json` and invocation image from a
Docker Application.

### WordPress application: [WordPress](wordpress)
### [Deploy a Helm Chart CNAB using Docker App](cnab-helm)

To learn how to create a basic WordPress with a database.

![WordPress app screenshot](.resources/wordpress.png "WordPress app screenshot")

### [CNAB simple application](cnab-simple)

Inspect and bundle a simple application as a [CNAB](https://cnab.io).

### [Deploy a Helm Chart using docker-app](cnab-helm)

As `docker-app` is a [CNAB](https://cnab.io) compliant client, you can deploy any CNAB.
As Docker App is a [CNAB](https://cnab.io) compliant client, you can deploy any
CNAB.
21 changes: 21 additions & 0 deletions examples/cnab-helm/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
26 changes: 13 additions & 13 deletions examples/cnab-helm/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
## Requirements
## Using a CNAB with Docker Application

* Any with Kubernetes enabled with [compose-on-kubernetes](https://github.com/docker/compose-on-kubernetes) installed
* [`docker-app` with CNAB support](https://github.com/docker/app/releases/tag/cnab-dockercon-preview) installed
### Requirements

* [Docker Desktop](https://www.docker.com/products/docker-desktop) with Kubernetes enabled or any other Kubernetes cluster
* Source code from this directory
* Create a context with `docker-app context`
* Set the `DOCKER_TARGET_CONTEXT` environment variable
* Helm configured for your Kubernetes cluster
* A `duffle` credential set created
* [Helm](https://helm.sh) configured for your Kubernetes cluster
* A `duffle` [credential set](https://github.com/deislabs/duffle/blob/1847f2f7127f13f62c1377f936cba522e8947dfb/docs/proposal/201-credentialset.md) created

## Examples
### Examples

Install the Helm chart example using `docker-app`
Install the Helm chart example using `docker app`

**Note**: This example comes from [deislabs/bundles](https://github.com/deislabs/bundles/tree/master/hellohelm).
**Note**: This example comes from
[deislabs/example-bundles](https://github.com/deislabs/example-bundles/tree/d1d95e25a2092ac170d9accd749dffa8babb2e05/hellohelm). See the [license file](./LICENSE) in this directory.

```console
$ docker-app install -c local bundle.json
$ docker app install --credential-set mycreds.yml bundle.json
Do install for hellohelm
helm install --namespace hellohelm -n hellohelm /cnab/app/charts/alpine
NAME: hellohelm
Expand All @@ -32,7 +32,7 @@ hellohelm-alpine 0s
Check the status of the Helm-based application:

```console
$ docker-app status -c local hellohelm
$ docker app status --credential-set mycreds.yml hellohelm
Do Status
helm status hellohelm
LAST DEPLOYED: Wed Nov 28 13:58:22 2018
Expand All @@ -48,7 +48,7 @@ hellohelm-alpine 2m
Uninstall the Helm-based application:

```console
docker-app uninstall -c local hellohelm
docker app uninstall --credential-set mycreds.yml hellohelm
Do Uninstall
helm delete --purge hellohelm
release "hellohelm" deleted
Expand Down
17 changes: 13 additions & 4 deletions examples/cnab-helm/bundle.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
{
"name": "hellohelm",
"version": "0.1.0",
"schemaVersion": "v1.0.0-WD",
"invocationImages": [
{
"imageType": "docker",
"image": "cnab/hellohelm:latest"
}
],
"images": [
{
"images": {
"alpine": {
"description": "alpine",
"image": "technosophos/demo2alpine:0.1.0",
"imageType": "docker",
Expand All @@ -19,16 +20,24 @@
}
]
}
],
},
"parameters": {
"port": {
"defaultValue": 8080,
"type": "int"
"type": "int",
"destination": {
"env": "PORT"
}
}
},
"credentials": {
"kubeconfig": {
"path": "/root/.kube/config"
}
},
"actions": {
"status": {
"modifies": false
}
}
}
2 changes: 1 addition & 1 deletion examples/cnab-helm/cnab/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM cnab/k8sbase:latest

COPY app/Makefile /cnab/app/Makefile
COPY app/charts /cnab/app/charts
COPY app/charts /cnab/app/charts
8 changes: 4 additions & 4 deletions examples/cnab-helm/cnab/app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ KUBECONFIG=/root/.kube/config
CNAB_ACTION ?= status
CNAB_INSTALLATION_NAME ?= helmtest

CNAB_P_HELM_OPTIONS ?= --dry-run --debug
CNAB_P_NAMESPACE ?= hellohelm
HELM_OPTIONS ?= --dry-run --debug
NAMESPACE ?= hellohelm

CHART=/cnab/app/charts/alpine

install:
@echo "Do $(CNAB_ACTION) for $(CNAB_INSTALLATION_NAME)"
helm install --namespace $(CNAB_P_NAMESPACE) -n $(CNAB_INSTALLATION_NAME) $(CHART)
helm install --namespace $(NAMESPACE) -n $(CNAB_INSTALLATION_NAME) $(CHART)

uninstall:
@echo "Do Uninstall"
helm delete --purge $(CNAB_INSTALLATION_NAME)

upgrade:
@echo "Do Upgrade"
helm upgrade --namespace $(CNAB_P_NAMESPACE) $(CNAB_INSTALLATION_NAME) $(CHART)
helm upgrade --namespace $(NAMESPACE) $(CNAB_INSTALLATION_NAME) $(CHART)

status:
@echo "Do Status"
Expand Down
2 changes: 1 addition & 1 deletion examples/cnab-helm/cnab/app/charts/alpine/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FROM alpine:3.7

CMD ["sleep", "9000"]
CMD ["sleep", "9000"]
5 changes: 5 additions & 0 deletions examples/cnab-helm/creds.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: mycreds
credentials:
- name: kubeconfig
source:
path: $HOME/.kube/config
5 changes: 0 additions & 5 deletions examples/cnab-helm/local.yaml

This file was deleted.

45 changes: 25 additions & 20 deletions examples/cnab-simple/README.md
Original file line number Diff line number Diff line change
@@ -1,61 +1,66 @@
## Requirements
# Docker Application to CNAB

* Working Docker Desktop install with Kubernetes enabled
* [`docker-app` with CNAB support](https://github.com/docker/app/releases/tag/cnab-dockercon-preview) installed
### Requirements

* [Docker Desktop](https://www.docker.com/products/docker-desktop) with Kubernetes enabled or any other Kubernetes cluster
* Source code from this directory
* Create a context with `docker-app context`
* Set the `DOCKER_TARGET_CONTEXT` environment variable

## Examples
### Examples

Show the details of the application with `inspect`

```console
$ docker-app inspect
hello 0.1.0
$ docker app inspect
hello 0.2.0

Maintained by: garethr <garethr@docker.com>
Maintained by: garethr <someone@example.com>

sample app for DockerCon
Sample app for DockerCon EU 2018

Service (1) Replicas Ports Image
----------- -------- ----- -----
hello 1 8765 hashicorp/http-echo:latest
hello 1 8765 hashicorp/http-echo:0.2.3

Parameters (3) Value
Parameters (2) Value
-------------- -----
port 8765
text hello DockerCon
version latest
text Hello DockerCon!
```

Install the application:

```console
$ docker-app install
$ docker app install
```

Show the details of the installation:

```console
$ docker-app status hello
$ docker app status hello
```

Upgrade the installation, demonstrating setting parameters:

```console
$ docker-app upgrade --set port=9876 --set text="hello DockerCon EU" hello
$ docker app upgrade --set port=9876 --set text="hello DockerCon EU" hello
```

Uninstall the application installation:

```console
$ docker-app uninstall hello
$ docker app uninstall hello
```

Demonstrate building a `bundle.json` for CNAB.

```console
$ docker-app bundle
Invocation image "hello:0.1.0-invoc" successfully built
$ docker app bundle
Invocation image "hello:0.2.0-invoc" successfully built
$ cat bundle.json
{
"name": "hello",
"version": "0.2.0",
"description": "Sample app for DockerCon EU 2018",
...
}
```

0 comments on commit dbe0367

Please sign in to comment.