Skip to content

Commit

Permalink
Merge pull request #6 from tantalic/kubernetes
Browse files Browse the repository at this point in the history
Add Kuberentes deployment
  • Loading branch information
tantalic authored Oct 4, 2016
2 parents 92d376d + 9714d1e commit 4de53a2
Show file tree
Hide file tree
Showing 11 changed files with 4,175 additions and 49 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
*.service
build/
build/
15 changes: 15 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM scratch
MAINTAINER Kevin Stock <[email protected]>

ADD certs/ca-certificates.crt /etc/ssl/certs/
ADD build/bellinghamcodes-linux-amd64 bellinghamcodes

ENV PORT 80
# ENV SLACK_TEAM
# ENV SLACK_TOKEN
# ENV MAILCHIMP_TOKEN
# ENV MAILCHIMP_LIST

EXPOSE 80

ENTRYPOINT ["/bellinghamcodes"]
15 changes: 5 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,11 @@ run:
install: bindata-assetfs
go install

osx: bindata-assetfs
env GOOS=darwin GOARCH=amd64 go build -o build/bellinghamcodes-darwin_amd64
env GOOS=darwin GOARCH=386 go build -o build/bellinghamcodes-darwin_386

linux: bindata-assetfs
env GOOS=linux GOARCH=amd64 go build -o build/bellinghamcodes-linux_amd64
env GOOS=linux GOARCH=386 go build -o build/bellinghamcodes-linux_386
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -a -tags netgo -ldflags '-w' -o build/bellinghamcodes-linux-amd64

freebsd: bindata-assetfs
env GOOS=freebsd GOARCH=amd64 go build -o build/bellinghamcodes-freebsd_amd64
env GOOS=freebsd GOARCH=386 go build -o build/bellinghamcodes-freebsd_386
docker: linux
docker build -t tantalic/bellinghamcodes-website:latest .

all: osx linux freebsd
update-ca:
curl --time-cond certs/ca-certificates.crt -o certs/ca-certificates.crt https://curl.haxx.se/ca/cacert.pem
65 changes: 28 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,52 +24,43 @@ To run for development purposes run:
make run
```

To cross-compile to another platform run one of the following:
## Running with Docker
To build the docker image run:
```sh
make linux
make freebsd
make osx
make docker
```

## Running (in Production)
Running the site will require the setting of a number of options. These options can be set via command line flags or environment variables.
The docker image generated will expose port 80 running the website.

| Environment Variable | Flag | Description | Default Value |
|----------------------|---------------------|------------------------------------------------------------------------------------------|---------------|
| `$PORT` | `--port` | The TCP port to listen on. | `3000` |
| `$HOST` | `--host` | The IP address/hostname to listen on. | All hosts |
| `$SLACK_TEAM` | `--slack-team` | Slack team name, as found in the slack URL. | `""` |
| `$SLACK_TOKEN` | `--slack-token` | Access token for your slack team. It can be generated at https://api.slack.com/web#auth. | `""` |
| `$MAILCHIMP_TOKEN` | `--mailchimp-token` | The API token for your MailChimp account. | `""` |
| `$MAILCHIMP_LIST` | `--mailchimp-list` | The ID of the MailChimp list. | `""` |
Additional configuration options are controlled through the following environment variables:

### systemd Configuration
The canonical way to run the site is through the [`systemd`][systemd] service manager to setup the environment, manage when the application is started, and monitor the process to keep it running. This can be done with a system file like the one below:
| Environment Variable | Description | Default Value |
|----------------------|------------------------------------------------------------------------------------------|---------------|
| `$SLACK_TEAM` | Slack team name, as found in the slack URL. | `""` |
| `$SLACK_TOKEN` | Access token for your slack team. It can be generated at https://api.slack.com/web#auth. | `""` |
| `$MAILCHIMP_TOKEN` | The API token for your MailChimp account. | `""` |
| `$MAILCHIMP_LIST` | The ID of the MailChimp list. | `""` |

. The following

```apacheconf
[Unit]
Description=bellingham.codes Website
For example:
```sh
docker run \
--detach \
--publish 8888:80 \
--env "SLACK_TEAM=bellinghamcodes" \
--env "SLACK_TOKEN=XXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXXXXX" \
--env "MAILCHIMP_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us1" \
--env "MAILCHIMP_LIST=XXXXXXXXXX" \
tantalic/bellinghamcodes-website:latest
```

[Service]
ExecStart=/usr/local/bin/bellinghamcodes
Restart=always
User=root
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=bellinghamcodes
Environment=PORT=80
Environment=SLACK_TEAM=bellinghamcodes
Environment=SLACK_TOKEN=XXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXXXXXX-XXXXXXXXXX
Environment=MAILCHIMP_TOKEN=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX-us1
Environment=MAILCHIMP_LIST=XXXXXXXXXX
## Running in Production
The production site runs on a [Kubernetes][k8s] cluster. To deploy on Kubernetes copy the `kubernetes/secrets.example.yaml` to `kubernetes/secrets.yaml` and complete the required values. Then run:

[Install]
WantedBy=multi-user.target
```sh
cd kubernetes/
./apply.sh
```


[go]: http://www.golang.org
[glide]: https://glide.sh
[systemd]: https://freedesktop.org/wiki/Software/systemd/
[k8s]: http://kubernetes.io
Loading

0 comments on commit 4de53a2

Please sign in to comment.