Skip to content

Commit

Permalink
Merge 821c8eb into 062b809
Browse files Browse the repository at this point in the history
  • Loading branch information
ddollar committed Sep 15, 2015
2 parents 062b809 + 821c8eb commit bba8680
Show file tree
Hide file tree
Showing 66 changed files with 575 additions and 2,886 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ Rack API client

Convox agent for ECS instances

### [cmd/app](https://github.com/convox/rack/tree/master/cmd/app)

Build CloudFormation stacks for Convox apps

### [cmd/build](https://github.com/convox/rack/tree/master/cmd/build)

Build and push Docker images for Convox apps

### [cmd/convox](https://github.com/convox/rack/tree/master/cmd/convox)

Convox CLI
Expand All @@ -33,10 +25,6 @@ Convox CLI

Encrypt/decrypt sensitive information

### [cmd/service](https://github.com/service/rack/tree/master/cmd/service)

Build CloudFormation stacks for external services

## Contributing

* Open a [GitHub Issue](https://github.com/convox/rack/issues/new) for bugs and feature requests
Expand Down
6 changes: 4 additions & 2 deletions api/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@ RUN apk-install docker git
COPY pkg/haproxy-1.5.10-r0.apk /tmp/haproxy-1.5.10-r0.apk
RUN apk add --allow-untrusted /tmp/haproxy-1.5.10-r0.apk
RUN rm /tmp/haproxy-1.5.10-r0.apk
COPY data/haproxy.cfg /etc/haproxy/haproxy.cfg
COPY conf/haproxy.cfg /etc/haproxy/haproxy.cfg

RUN apk-install go
ENV GOPATH /go
ENV PATH $GOPATH/bin:$PATH

RUN go get github.com/ddollar/init
RUN go get github.com/ddollar/rerun
RUN go get -u github.com/jteeuwen/go-bindata/...

ENV PORT 3000
WORKDIR /go/src/github.com/convox/rack/api
COPY . /go/src/github.com/convox/rack/api
RUN go get .
RUN go get ./...
RUN go-bindata -pkg=models -prefix=models -o=models/templates.go models/templates/...

ENTRYPOINT ["/go/bin/init"]
CMD ["bin/web"]
3 changes: 3 additions & 0 deletions api/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ release:
jq '.Parameters.Version.Default |= "$(VERSION)"' dist/kernel.json > /tmp/kernel.json
aws s3 cp /tmp/kernel.json s3://convox/release/$(VERSION)/formation.json --acl public-read

templates:
go-bindata -pkg=models -prefix=models -o=models/templates.go models/templates/...

test:
go get -t ./...
go test -v -cover ./...
Expand Down
11 changes: 1 addition & 10 deletions api/bin/web
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
#!/bin/sh

pull_image() {
image=$1
echo "ns=kernel at=boot pull=$image"
docker pull $image >/dev/null 2>&1 &
}

pull_image $DOCKER_IMAGE_APP
pull_image $DOCKER_IMAGE_BUILD
pull_image $DOCKER_IMAGE_SERVICE

./bin/gen-cert

haproxy -f /etc/haproxy/haproxy.cfg &

if [ "$DEVELOPMENT" == "true" ]; then
Expand Down
2 changes: 2 additions & 0 deletions api/cmd/build/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
/build
2 changes: 2 additions & 0 deletions api/cmd/build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.env
/build
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmd/build/main.go → api/cmd/build/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
"syscall"
"time"

"github.com/convox/rack/manifest"
"github.com/convox/rack/api/manifest"
)

func init() {
Expand Down
File renamed without changes.
File renamed without changes.
54 changes: 10 additions & 44 deletions api/dist/kernel.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"Conditions": {
"BlankAmi": { "Fn::Equals": [ { "Ref": "Ami" }, "" ] },
"BlankCertificate": { "Fn::Equals": [ { "Ref": "Certificate" }, "" ] },
"BlankDockerImageApp": { "Fn::Equals": [ { "Ref": "DockerImageApp" }, "" ] },
"BlankDockerImageBuild": { "Fn::Equals": [ { "Ref": "DockerImageBuild" }, "" ] },
"BlankDockerImageService": { "Fn::Equals": [ { "Ref": "DockerImageService" }, "" ] },
"BlankDockerImageApi": { "Fn::Equals": [ { "Ref": "DockerImageApi" }, "" ] },
"BlankKey": { "Fn::Equals": [ { "Ref": "Key" }, "" ] },
"BlankRegistryHost": { "Fn::Equals": [ { "Ref": "RegistryHost" }, "" ] },
"Development": { "Fn::Equals": [ { "Ref": "Development" }, "Yes" ] }
Expand Down Expand Up @@ -44,25 +42,11 @@
"Dashboard": {
"Value": { "Fn::GetAtt": [ "Balancer", "DNSName" ] }
},
"DockerImageApp": {
"DockerImageApi": {
"Condition": "Development",
"Value": { "Fn::If": [ "BlankDockerImageApp",
{ "Fn::Join": [ ":", [ "convox/app", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageApp" }
] }
},
"DockerImageBuild": {
"Condition": "Development",
"Value": { "Fn::If": [ "BlankDockerImageBuild",
{ "Fn::Join": [ ":", [ "convox/build", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageBuild" }
] }
},
"DockerImageService": {
"Condition": "Development",
"Value": { "Fn::If": [ "BlankDockerImageService",
{ "Fn::Join": [ ":", [ "convox/service", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageService" }
"Value": { "Fn::If": [ "BlankDockerImageApi",
{ "Fn::Join": [ ":", [ "convox/api", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageApi" }
] }
},
"DynamoBuilds": {
Expand Down Expand Up @@ -126,19 +110,9 @@
"Default": "No",
"AllowedValues": [ "Yes", "No" ]
},
"DockerImageApp": {
"Type": "String",
"Description": "Image to use for the app container. Overrides current Version.",
"Default": ""
},
"DockerImageBuild": {
"DockerImageApi": {
"Type": "String",
"Description": "Image to use for the build container. Overrides current Version.",
"Default": ""
},
"DockerImageService": {
"Type": "String",
"Description": "Image to use for the service container. Overrides current Version.",
"Description": "Image to use for the api container. Overrides current Version.",
"Default": ""
},
"InstanceCount": {
Expand Down Expand Up @@ -839,17 +813,9 @@
"CLIENT_ID": { "Ref": "ClientId" },
"CUSTOM_TOPIC": { "Fn::GetAtt": [ "CustomTopic", "Arn" ] },
"CLUSTER": { "Ref": "Cluster" },
"DOCKER_IMAGE_APP": { "Fn::If": [ "BlankDockerImageApp",
{ "Fn::Join": [ ":", [ "convox/app", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageApp" }
] },
"DOCKER_IMAGE_BUILD": { "Fn::If": [ "BlankDockerImageBuild",
{ "Fn::Join": [ ":", [ "convox/build", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageBuild" }
] },
"DOCKER_IMAGE_SERVICE": { "Fn::If": [ "BlankDockerImageService",
{ "Fn::Join": [ ":", [ "convox/service", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageService" }
"DOCKER_IMAGE_API": { "Fn::If": [ "BlankDockerImageApi",
{ "Fn::Join": [ ":", [ "convox/api", { "Ref": "Version" } ] ] },
{ "Ref": "DockerImageApi" }
] },
"DYNAMO_BUILDS": { "Ref": "DynamoBuilds" },
"DYNAMO_RELEASES": { "Ref": "DynamoReleases" },
Expand Down
6 changes: 2 additions & 4 deletions api/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ web:
- CLIENT_ID=dev@convox.com
- CLUSTER
- CUSTOM_TOPIC
- DOCKER_IMAGE_APP
- DOCKER_IMAGE_BUILD
- DOCKER_IMAGE_SERVICE
- DOCKER_IMAGE_API=api/web
- DYNAMO_BUILDS
- DYNAMO_RELEASES
- ENCRYPTION_KEY
Expand All @@ -26,7 +24,7 @@ web:
- 80:3000
- 443:4443
volumes:
- ./:/go/src/github.com/convox/kernel
- ./:/go/src/github.com/convox/rack/api
- /var/run/docker.sock:/var/run/docker.sock
registry:
environment:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions manifest/manifest_test.go → api/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func TestBuild(t *testing.T) {
t.Skip("skipping until i can figure out regex")
return

destDir := mkBuildDir(t, "../examples/compose")
destDir := mkBuildDir(t, "../../examples/compose")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand All @@ -42,7 +42,7 @@ RUNNING: docker tag -f xvlbzgbaic compose/web
}

func TestPortsWanted(t *testing.T) {
destDir := mkBuildDir(t, "../examples/compose")
destDir := mkBuildDir(t, "../../examples/compose")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand Down Expand Up @@ -85,7 +85,7 @@ postgres:
}

func TestRun(t *testing.T) {
destDir := mkBuildDir(t, "../examples/compose")
destDir := mkBuildDir(t, "../../examples/compose")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand All @@ -101,7 +101,7 @@ func TestRun(t *testing.T) {
}

func TestGenerateDockerCompose(t *testing.T) {
destDir := mkBuildDir(t, "../examples/compose")
destDir := mkBuildDir(t, "../../examples/compose")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand All @@ -125,7 +125,7 @@ postgres:
}

func TestGenerateDockerfile(t *testing.T) {
destDir := mkBuildDir(t, "../examples/dockerfile")
destDir := mkBuildDir(t, "../../examples/dockerfile")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand All @@ -143,7 +143,7 @@ func TestGenerateDockerfile(t *testing.T) {
}

func TestGenerateProcfile(t *testing.T) {
destDir := mkBuildDir(t, "../examples/procfile")
destDir := mkBuildDir(t, "../../examples/procfile")
defer os.RemoveAll(destDir)

m, _ := Generate(destDir)
Expand Down
3 changes: 1 addition & 2 deletions api/models/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"io"
"net"
"os"
"os/exec"
"regexp"
"time"

Expand Down Expand Up @@ -220,7 +219,7 @@ func (a *App) UpdateParams(changes map[string]string) error {
}

func (a *App) Formation() (string, error) {
data, err := exec.Command("docker", "run", os.Getenv("DOCKER_IMAGE_APP"), "-mode", "staging").Output()
data, err := buildTemplate("app", "app", Manifest{})

if err != nil {
return "", err
Expand Down
4 changes: 2 additions & 2 deletions api/models/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (b *Build) ExecuteLocal(r io.Reader, ch chan error) {

name := b.App

args := []string{"run", "-i", "--name", fmt.Sprintf("build-%s", b.Id), "-v", "/var/run/docker.sock:/var/run/docker.sock", os.Getenv("DOCKER_IMAGE_BUILD"), "-id", b.Id, "-push", os.Getenv("REGISTRY_HOST")}
args := []string{"run", "-i", "--name", fmt.Sprintf("build-%s", b.Id), "-v", "/var/run/docker.sock:/var/run/docker.sock", os.Getenv("DOCKER_IMAGE_API"), "build", "-id", b.Id, "-push", os.Getenv("REGISTRY_HOST")}

if pw := os.Getenv("PASSWORD"); pw != "" {
args = append(args, "-auth", pw)
Expand All @@ -175,7 +175,7 @@ func (b *Build) ExecuteRemote(repo string, ch chan error) {

name := b.App

args := []string{"run", "--name", fmt.Sprintf("build-%s", b.Id), "-v", "/var/run/docker.sock:/var/run/docker.sock", os.Getenv("DOCKER_IMAGE_BUILD"), "-id", b.Id, "-push", os.Getenv("REGISTRY_HOST")}
args := []string{"run", "--name", fmt.Sprintf("build-%s", b.Id), "-v", "/var/run/docker.sock:/var/run/docker.sock", os.Getenv("DOCKER_IMAGE_API"), "build", "-id", b.Id, "-push", os.Getenv("REGISTRY_HOST")}

if pw := os.Getenv("PASSWORD"); pw != "" {
args = append(args, "-auth", pw)
Expand Down
Loading

0 comments on commit bba8680

Please sign in to comment.