Skip to content

Commit 1c8bbf8

Browse files
committed
chore: Add scaffold files.
1 parent 1739b86 commit 1c8bbf8

10 files changed

Lines changed: 203 additions & 13 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
rootfs/bin/boot
2+
vendor/*

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Changlog for PROJECTNAME
2+
3+
This is a placeholder for a markdown-formatted changelog.

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# How to Contribute
2+
3+
This project is part of Deis. You can find the latest contribution
4+
guidelines [at the Deis project](https://github.com/deis/deis/blob/master/CONTRIBUTING.md).
5+

DCO

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
Developer Certificate of Origin
2+
Version 1.1
3+
4+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5+
660 York Street, Suite 102,
6+
San Francisco, CA 94110 USA
7+
8+
Everyone is permitted to copy and distribute verbatim copies of this
9+
license document, but changing it is not allowed.
10+
11+
12+
Developer's Certificate of Origin 1.1
13+
14+
By making a contribution to this project, I certify that:
15+
16+
(a) The contribution was created in whole or in part by me and I
17+
have the right to submit it under the open source license
18+
indicated in the file; or
19+
20+
(b) The contribution is based upon previous work that, to the best
21+
of my knowledge, is covered under an appropriate open source
22+
license and I have the right under that license to submit that
23+
work with modifications, whether created in whole or in part
24+
by me, under the same open source license (unless I am
25+
permitted to submit under a different license), as indicated
26+
in the file; or
27+
28+
(c) The contribution was provided directly to me by some other
29+
person who certified (a), (b) or (c) and I have not modified
30+
it.
31+
32+
(d) I understand and agree that this project and the contribution
33+
are public and that a record of the contribution (including all
34+
personal information I submit with it, including my sign-off) is
35+
maintained indefinitely and may be redistributed consistent with
36+
this project or the open source license(s) involved.

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright 2015 Engine Yard, Inc.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

MAINTAINERS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Deis Maintainers
2+
3+
This project is part of Deis. The official maintainers documentation is
4+
located [in the main project](https://github.com/deis/deis/blob/master/MAINTAINERS.md).

Makefile

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,68 @@
1-
include ../includes.mk
1+
# Short name: Short name, following [a-zA-Z_], used all over the place.
2+
# Some uses for short name:
3+
# - Docker image name
4+
# - Kubernetes service, rc, pod, secret, volume names
5+
SHORT_NAME := example
26

3-
repo_path = github.com/deis/deis/pkg
7+
# Enable vendor/ directory support.
8+
export GO15VENDOREXPERIMENT=1
49

5-
GO_PACKAGES = prettyprint time
6-
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
10+
# SemVer with build information is defined in the SemVer 2 spec, but Docker
11+
# doesn't allow +, so we use -.
12+
VERSION := 0.0.1-$(shell date "+%Y%m%d%H%M%S")
713

8-
test: test-style test-unit
14+
# Common flags passed into Go's linker.
15+
LDFLAGS := "-s -X main.version=${VERSION}"
916

10-
test-style:
11-
# display output, then check
12-
$(GOFMT) $(GO_PACKAGES)
13-
@$(GOFMT) $(GO_PACKAGES) | read; if [ $$? == 0 ]; then echo "gofmt check failed."; exit 1; fi
14-
$(GOVET) $(GO_PACKAGES_REPO_PATH)
15-
$(GOLINT) ./...
17+
# Docker Root FS
18+
BINDIR := ./rootfs
1619

17-
test-unit:
18-
$(GOTEST) ./...
20+
# Legacy support for DEV_REGISTRY, plus new support for DEIS_REGISTRY.
21+
DEV_REGISTRY ?= $(eval docker-machine ip deis):5000
22+
DEIS_REGISTY ?= ${DEV_REGISTRY}
23+
24+
# Kubernetes-specific information for RC, Service, and Image.
25+
RC := manifests/deis-${SHORT_NAME}-rc.yaml
26+
SVC := manifests/deis-${SHORT_NAME}-service.yaml
27+
IMAGE := ${DEIS_REGISTRY}/deis/${SHORT_NAME}:${VERSION}
28+
29+
all:
30+
@echo "Use a Makefile to control top-level building of the project."
31+
32+
# This illustrates a two-stage Docker build. docker-compile runs inside of
33+
# the Docker environment. Other alternatives are cross-compiling, doing
34+
# the build as a `docker build`.
35+
build:
36+
mkdir -p ${BINDIR}/bin
37+
docker run --rm -v ${PWD}:/app -w /app golang:1.5.1 make docker-compile
38+
39+
# For cases where build is run inside of a container.
40+
docker-compile:
41+
go build -o ${BINDIR}/bin/boot -a -installsuffix cgo -ldflags ${LDFLAGS} boot.go
42+
43+
# For cases where we're building from local
44+
# We also alter the RC file to set the image name.
45+
docker-build:
46+
docker build --rm -t ${IMAGE} rootfs
47+
perl -pi -e "s|[a-z0-9.:]+\/deis\/${SHORT_NAME}:[0-9a-z-.]+|${IMAGE}|g" ${RC}
48+
49+
# Push to a registry that Kubernetes can access.
50+
docker-push:
51+
docker push ${IMAGE}
52+
53+
# Deploy is a Kubernetes-oriented target
54+
deploy: kube-service kube-rc
55+
56+
# Some things, like services, have to be deployed before pods. This is an
57+
# example target. Others could perhaps include kube-secret, kube-volume, etc.
58+
kube-service:
59+
kubectl create -f ${SVC}
60+
61+
# When possible, we deploy with RCs.
62+
kube-rc:
63+
kubectl create -f ${RC}
64+
65+
kube-clean:
66+
kubectl delete rc deis-example
67+
68+
.PHONY: all build docker-compile kube-up kube-down deploy

README.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Prototype Component Repo
2+
3+
This repo is a prototype for what a Deis component's Git repository
4+
should look like.
5+
6+
A Deis component is...
7+
8+
- An isolated piece of functionality (e.g. a microservice)
9+
- That can be packaged into a container (via `docker build`)
10+
- And can be run inside of Kubernetes
11+
12+
Typically, Deis components are written in Go.
13+
14+
## Practical Usage
15+
16+
If you want to experiment with creating a new repo using this framework,
17+
try something like this:
18+
19+
```
20+
$ mkdir my_project
21+
$ cd my_project
22+
$ curl -fsSL https://github.com/technosophos/prototype-repo/archive/master.tar.gz | tar -zxv --strip-components 1
23+
```
24+
25+
## First-Class Kubernetes
26+
27+
Every component must define the appropriate Kubernetes files.
28+
Preferably, components should use *Replication Controllers* over pods,
29+
and use *Services* for autodiscovery.
30+
31+
*Labels* should be used for versioning components and also for
32+
identifying components as part of Deis.
33+
34+
*Secrets* should be used for storing small bits of shared information,
35+
and their contents may be set at startup time.
36+
37+
All Kubernetes definitions should be placed in the `manifests/` directory.
38+
39+
The _Makefile_ should have targets that use `kubectl` to load
40+
definitions into Kubernetes.
41+
42+
## Dockerfiles are for Running
43+
44+
Source code should be built either outside of Docker or in a special
45+
Docker build phase.
46+
47+
A separate Dockerfile should be used for building the image. That
48+
Dockerfile should always be placed inside of the `rootfs` directory, and
49+
should manage the final image size appropriately.
50+
51+
(See the Makefile for one possible way of doing a Docker build phase)
52+
53+
## RootFS
54+
55+
All files that are to be packaged into the container should be written
56+
to the `rootfs/` folder.
57+
58+
## Extended Testing
59+
60+
Along with unit tests, Deis values functional and integration testing.
61+
These tests should go in the `_tests` folder.

_docs/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Project Docs
2+
3+
Documentation for the project should be stored in the `_docs` directory.
4+
Since the directory is protected from Go, undecorated code samples can
5+
also be dropped inside of this directory.
6+
7+
We need to decide on whether we'll continue using RST or switch to
8+
Markdown.
9+
10+
I believe we are leaning toward MkDocs: http://www.mkdocs.org/

_tests/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Tests
2+
3+
This directory is used for functional tests.
4+
5+
The directory is prefixed with an underscore (`_tests`) to prevent Go
6+
tools from automatically running Go code found in this directory.

0 commit comments

Comments
 (0)