Skip to content

Commit

Permalink
add registry to amp with HAProxy reverse proxy (#155)
Browse files Browse the repository at this point in the history
* add registry

* update haproxy

* update image list

* update registry volume

* add amp command: push

* add persistence to registry

* minor format update
  • Loading branch information
freignat91 authored and subfuzion committed Sep 14, 2016
1 parent 041cbf2 commit bc774a2
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 2 deletions.
61 changes: 61 additions & 0 deletions cmd/amp/registry.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package main

import (
"errors"
"fmt"
"os"
"os/exec"

"github.com/appcelerator/amp/api/client"
"github.com/spf13/cobra"
)

var pushCmd = &cobra.Command{
Use: "push",
Short: "push an image in the amp registry",
Long: `push an image to the amp registry`,
Run: func(cmd *cobra.Command, args []string) {
err := RegistryPush(AMP, cmd, args)
if err != nil {
fmt.Println(err)
}
},
}

func init() {
RootCmd.AddCommand(pushCmd)
}

// RegistryPush displays resource usage statistcs
func RegistryPush(amp *client.AMP, cmd *cobra.Command, args []string) error {
_, err := amp.GetAuthorizedContext()
if err != nil {
return err
}

image := args[0]

if amp.Verbose() {
fmt.Println("Execute registry push command with:")
fmt.Printf("image: %s\n", image)
}

if err = validateRegistryImage(image); err != nil {
return err
}
cmdexe := exec.Command("docker", "push", image)
cmdexe.Stdout = os.Stdout
cmdexe.Stderr = os.Stderr
err = cmdexe.Run()
if err != nil {
return err
}
return err
}

func validateRegistryImage(image string) error {
if image == "" {
return errors.New("need a valid image name")
}
return nil
}
15 changes: 13 additions & 2 deletions swarm
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ IMAGES=(
appcelerator/kapacitor:kapacitor-${INFLUXDATA_VERSION}
appcelerator/kibana:latest
appcelerator/telegraf:telegraf-${INFLUXDATA_VERSION}
registry:2
appcelerator/zookeeper:${ZOOKEEPER_VERSION}
quay.io/coreos/etcd:v3.0.4
)

MINIMAGES=(
appcelerator/amplifier:latest
appcelerator/amplifier:latest
appcelerator/amp-agent:latest
appcelerator/amp-log-worker:latest
appcelerator/elasticsearch-amp:latest
Expand All @@ -41,6 +42,7 @@ MINIMAGES=(
appcelerator/kafka:${KAFKA_VERSION}
appcelerator/kibana:latest
appcelerator/telegraf:telegraf-${INFLUXDATA_VERSION}
registry:2
appcelerator/zookeeper:${ZOOKEEPER_VERSION}
quay.io/coreos/etcd:v3.0.4
)
Expand All @@ -60,6 +62,7 @@ SERVICES=(
kibana
kapacitor
telegrafagent
registry
zookeeper
)

Expand All @@ -74,6 +77,7 @@ MINSERVICES=(
influxdb
kibana
telegrafagent
registry
zookeeper
)

Expand Down Expand Up @@ -208,6 +212,14 @@ monitor() {
clear; while true; do tput cup 0 0; docker service ls; sleep $interval; done
}

registry() { # Owner: freignat91
docker service create --network amp-swarm --name registry \
--label amp.swarm="infrastructure" \
--mount type=bind,source=$HOME/registry/data,target=/var/lib/registry \
-p 5000:5000 \
registry:2
}

amplifier() {
docker service create --network amp-swarm,amp-public --name amplifier \
--label amp.swarm="infrastructure" \
Expand All @@ -218,7 +230,6 @@ ampagent() { # Owner: freignat91
docker service create --network amp-swarm --name amp-agent \
--mode global \
--label amp.swarm="infrastructure" \
-p 5001:3000 \
--mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
appcelerator/amp-agent:latest
}
Expand Down

0 comments on commit bc774a2

Please sign in to comment.