Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0fc8879

Browse files
author
Eric Chiang
committed
*: prepare build scripts for a release
1 parent c50b44c commit 0fc8879

7 files changed

Lines changed: 157 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
bin
22
dist
3+
_output

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: go
22

33
go:
4-
- 1.7
4+
- 1.7.1
55

66
services:
77
- postgresql

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
FROM alpine:latest
1+
FROM alpine:3.4
22

33
MAINTAINER Eric Chiang <[email protected]>
44

55
RUN apk add --update ca-certificates
66

7-
COPY bin/dex /dex
7+
COPY _output/bin/dex /usr/local/bin/dex
88

9-
ENTRYPOINT ["/dex"]
9+
ENTRYPOINT ["/usr/local/bin/dex"]
1010

1111
CMD ["version"]

Documentation/dev-releases.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Releases
2+
3+
Making a dex release involves:
4+
5+
* Tagging a git commit and pushing the tag to GitHub.
6+
* Building and pushing a Docker image.
7+
* Building, signing, and hosting an ACI.
8+
9+
This requires the following tools.
10+
11+
* rkt
12+
* Docker
13+
* [docker2aci](https://github.com/appc/docker2aci)
14+
* [acbuild](https://github.com/containers/build) (must be in your sudo user's PATH)
15+
16+
And the following permissions.
17+
18+
* Push access to the github.com/coreos/dex git repo.
19+
* Push access to the quay.io/coreos/dex Docker repo.
20+
* Access to the CoreOS application signing key.
21+
22+
## Tagging the release
23+
24+
Make sure you've [uploaded your GPG key](https://github.com/settings/keys) and
25+
configured git to [use that signing key](
26+
https://git-scm.com/book/en/v2/Git-Tools-Signing-Your-Work) either globally or
27+
for the Dex repo. Note that the email the key is issued for must be the email
28+
you use for git.
29+
30+
```
31+
git config [--global] user.signingkey "{{ GPG key ID }}"
32+
git config [--global] user.email "{{ Email associated with key }}"
33+
```
34+
35+
Create a signed tag at the commit you wish to release. This action will prompt
36+
you to enter a tag message, which can just be the release version.
37+
38+
```
39+
git tag -s v2.1.0-alpha ea4c04fde83bd6c48f4d43862c406deb4ea9dba2
40+
```
41+
42+
Push that tag to the CoreOS repo.
43+
44+
```
45+
git push [email protected]:coreos/dex.git v2.1.0-alpha
46+
```
47+
48+
Draft releases on GitHub and summarize the changes since the last release. See
49+
previous releases for the expected format.
50+
51+
https://github.com/coreos/dex/releases
52+
53+
## Building the Docker image
54+
55+
Build the Docker image and push to Quay.
56+
57+
```bash
58+
# checkout the tag
59+
git checkout tags/v2.1.0-alpha
60+
# rkt doesn't play nice with SELinux, see https://github.com/coreos/rkt/issues/1727
61+
sudo setenforce Permissive
62+
# will prompt for sudo password
63+
make docker-image
64+
sudo docker push quay.io/coreos/dex:v2.1.0-alpha
65+
```
66+
67+
## Building the ACI
68+
69+
```bash
70+
# checkout the tag
71+
git checkout tags/v2.1.0-alpha
72+
# rkt doesn't play nice with SELinux, see https://github.com/coreos/rkt/issues/1727
73+
sudo setenforce Permissive
74+
# will prompt for sudo password
75+
make aci
76+
# aci will be built at _output/image/dex.aci
77+
```
78+
79+
Sign the ACI using the CoreOS application signing key. Upload the ACI and
80+
signature to the GitHub release.

Makefile

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ export PATH := $(PWD)/bin:$(PATH)
55

66
VERSION=$(shell ./scripts/git-version)
77

8-
DOCKER_REPO=quay.io/ericchiang/dex
8+
DOCKER_REPO=quay.io/coreos/dex
99
DOCKER_IMAGE=$(DOCKER_REPO):$(VERSION)
1010

1111
$( shell mkdir -p bin )
12+
$( shell mkdir -p _output/images )
13+
$( shell mkdir -p _output/bin )
14+
15+
user=$(shell id -u -n)
16+
group=$(shell id -g -n)
1217

1318
export GOBIN=$(PWD)/bin
1419
# Prefer ./bin instead of system packages for things like protoc, where we want
@@ -51,15 +56,28 @@ lint:
5156
server/templates_default.go: $(wildcard web/templates/**)
5257
@go run server/templates_default_gen.go
5358

54-
.PHONY: docker-build
55-
docker-build: bin/dex
56-
@docker build -t $(DOCKER_IMAGE) .
59+
_output/bin/dex:
60+
# Using rkt to build the dex binary.
61+
@./scripts/rkt-build
62+
@sudo chown $(user):$(group) _output/bin/dex
63+
64+
_output/images/library-alpine-3.4.aci:
65+
@mkdir -p _output/images
66+
# Using docker2aci to get a base ACI to build from.
67+
@docker2aci docker://alpine:3.4
68+
@mv library-alpine-3.4.aci _output/images/library-alpine-3.4.aci
5769

58-
.PHONY: docker-push
59-
docker-push: docker-build
60-
@docker tag $(DOCKER_IMAGE) $(DOCKER_REPO):latest
61-
@docker push $(DOCKER_IMAGE)
62-
@docker push $(DOCKER_REPO):latest
70+
_output/images/dex.aci: _output/bin/dex _output/images/library-alpine-3.4.aci
71+
# Using acbuild to build a application container image.
72+
@sudo ./scripts/build-aci ./_output/images/library-alpine-3.4.aci
73+
@sudo chown $(user):$(group) _output/images/dex.aci
74+
75+
.PHONY: aci
76+
aci: _output/images/dex.aci
77+
78+
.PHONY: docker-image
79+
docker-image: _output/bin/dex
80+
@docker build -t $(DOCKER_IMAGE) .
6381

6482
.PHONY: grpc
6583
grpc: api/api.pb.go
@@ -74,7 +92,8 @@ bin/protoc-gen-go:
7492
@go install -v $(REPO_PATH)/vendor/github.com/golang/protobuf/protoc-gen-go
7593

7694
clean:
77-
@rm bin/*
95+
@rm -rf bin/
96+
@rm -rf _output/
7897

7998
testall: testrace vet fmt lint
8099

scripts/build-aci

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$EUID" -ne 0 ]; then
6+
echo "This script uses functionality which requires root privileges"
7+
exit 1
8+
fi
9+
10+
# Start the build with an empty ACI
11+
acbuild --debug begin $1
12+
13+
# In the event of the script exiting, end the build
14+
trap "{ export EXT=$?; sudo acbuild --debug end && exit $EXT; }" EXIT
15+
16+
# Name the ACI
17+
acbuild --debug set-name coreos.com/dex
18+
19+
# Add a version label
20+
acbuild --debug label add version $( ./scripts/git-version )
21+
22+
acbuild --debug run -- apk add --update ca-certificates
23+
24+
acbuild --debug copy _output/bin/dex /usr/local/bin/dex
25+
26+
acbuild --debug port add www tcp 5556
27+
acbuild --debug port add grcp tpc 5557
28+
29+
acbuild --debug set-exec -- /usr/local/bin/dex
30+
acbuild --debug write --overwrite _output/images/dex.aci

scripts/rkt-build

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
mkdir -p _output/bin
4+
5+
sudo rkt run \
6+
--volume dex,kind=host,source=$PWD \
7+
--mount volume=dex,target=/go/src/github.com/coreos/dex \
8+
--dns=8.8.8.8 \
9+
--net=host \
10+
--insecure-options=image \
11+
docker://golang:1.7.1-alpine \
12+
--exec=/bin/sh -- -x -c \
13+
'apk add --no-cache --update alpine-sdk && go install -v github.com/coreos/dex/cmd/dex && cp /go/bin/dex /go/src/github.com/coreos/dex/_output/bin'

0 commit comments

Comments
 (0)