Skip to content

Commit be85a5e

Browse files
committed
add Makefile build and deploy docker image for step-ca
1 parent baaff35 commit be85a5e

File tree

3 files changed

+142
-2
lines changed

3 files changed

+142
-2
lines changed

Makefile

Lines changed: 66 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Q=$(if $V,,@)
66
PREFIX?=
77
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
88
GOOS_OVERRIDE ?=
9+
OUTPUT_ROOT=output/
910

1011
# Set shell to bash for `echo -e`
1112
SHELL := /bin/bash
@@ -152,6 +153,70 @@ uninstall:
152153

153154
.PHONY: install uninstall
154155

156+
#########################################
157+
# Building Docker Image
158+
#
159+
# Builds a dockerfile for step by building a linux version of the step-cli and
160+
# then copying the specific binary when building the container.
161+
#
162+
# This ensures the container is as small as possible without having to deal
163+
# with getting access to private repositories inside the container during build
164+
# time.
165+
#########################################
166+
167+
# XXX We put the output for the build in 'output' so we don't mess with how we
168+
# do rule overriding from the base Makefile (if you name it 'build' it messes up
169+
# the wildcarding).
170+
DOCKER_OUTPUT=$(OUTPUT_ROOT)docker/
171+
172+
DOCKER_MAKE=V=$V GOOS_OVERRIDE='GOOS=linux GOARCH=amd64' PREFIX=$(1) make $(1)bin/$(2)
173+
DOCKER_BUILD=$Q docker build -t smallstep/$(1):latest -f docker/$(2) --build-arg BINPATH=$(DOCKER_OUTPUT)bin/$(1) .
174+
175+
docker: docker-make docker/Dockerfile.step-ca
176+
$(call DOCKER_BUILD,step-ca,Dockerfile.step-ca)
177+
178+
docker-make:
179+
mkdir -p $(DOCKER_OUTPUT)
180+
$(call DOCKER_MAKE,$(DOCKER_OUTPUT),step-ca)
181+
182+
.PHONY: docker docker-make
183+
184+
#################################################
185+
# Releasing Docker Images
186+
#
187+
# Using the docker build infrastructure, this section is responsible for
188+
# logging into docker hub and pushing the built docker containers up with the
189+
# appropriate tags.
190+
#################################################
191+
192+
DOCKER_TAG=docker tag smallstep/$(1):latest smallstep/$(1):$(2)
193+
DOCKER_PUSH=docker push smallstep/$(1):$(2)
194+
195+
docker-tag:
196+
$(call DOCKER_TAG,step-ca,$(VERSION))
197+
198+
docker-push-tag: docker-tag
199+
$(call DOCKER_PUSH,step-ca,$(VERSION))
200+
201+
# Rely on DOCKER_USERNAME and DOCKER_PASSWORD being set inside the CI or
202+
# equivalent environment
203+
docker-login:
204+
$Q docker login -u="$(DOCKER_USERNAME)" -p="$(DOCKER_PASSWORD)"
205+
206+
.PHONY: docker-login docker-tag docker-push-tag
207+
208+
#################################################
209+
# Targets for pushing the docker images
210+
#################################################
211+
212+
# For all builds on the master branch, we actually build the container
213+
docker-master: docker
214+
215+
# For all builds on the master branch with an rc tag
216+
docker-release: docker-master docker-login docker-push-tag
217+
218+
.PHONY: docker-master docker-release
219+
155220
#########################################
156221
# Debian
157222
#########################################
@@ -177,7 +242,6 @@ distclean: clean
177242
# Build statically compiled step binary for various operating systems
178243
#################################################
179244

180-
OUTPUT_ROOT=output/
181245
BINARY_OUTPUT=$(OUTPUT_ROOT)binary/
182246
BUNDLE_MAKE=v=$v GOOS_OVERRIDE='GOOS=$(1) GOARCH=$(2)' PREFIX=$(3) make $(3)bin/$(BINNAME)
183247
RELEASE=./.travis-releases
@@ -234,7 +298,7 @@ artifacts-master:
234298
artifacts-release: artifacts-tag
235299

236300
# This command is called by travis directly *after* a successful build
237-
artifacts: artifacts-$(PUSHTYPE)
301+
artifacts: artifacts-$(PUSHTYPE) docker-$(PUSHTYPE)
238302

239303
.PHONY: artifacts-master artifacts-release artifacts
240304

docker/Dockerfile.step-ca

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM smallstep/step-cli:0.0.2-rc.17
2+
3+
ARG CFGPATH="docker/ca.json"
4+
ARG BINPATH="bin/step-ca"
5+
6+
ENV PORT=8000
7+
ENV CONFIGPATH="/home/step/ca.json"
8+
ENV PWDPATH="/home/step/secrets/password"
9+
10+
COPY $CFGPATH $CONFIGPATH
11+
COPY $BINPATH "/usr/local/bin/step-ca"
12+
13+
EXPOSE $PORT
14+
VOLUME ["/home/step/.step/secrets"]
15+
VOLUME ["/home/step/secrets"]
16+
STOPSIGNAL SIGTERM
17+
18+
CMD /bin/sh -c "/usr/local/bin/step-ca $CONFIGPATH --password-file=$PWDPATH"

docker/ca.json

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"root": "examples/pki/secrets/root_ca.crt",
3+
"crt": "examples/pki/secrets/intermediate_ca.crt",
4+
"key": "examples/pki/secrets/intermediate_ca_key",
5+
"password": "password",
6+
"address": ":9000",
7+
"dnsNames": [
8+
"localhost"
9+
],
10+
"logger": {
11+
"format": "text"
12+
},
13+
"authority": {
14+
"provisioners": [
15+
{
16+
"name": "[email protected]",
17+
"type": "jwk",
18+
"key": {
19+
"use": "sig",
20+
"kty": "EC",
21+
"kid": "DmAtZt2EhmZr_iTJJ387fr4Md2NbzMXGdXQNW1UWPXk",
22+
"crv": "P-256",
23+
"alg": "ES256",
24+
"x": "jXoO1j4CXxoTC32pNzkVC8l6k2LfP0k5ndhJZmcdVbk",
25+
"y": "c3JDL4GTFxJWHa8EaHdMh4QgwMh64P2_AGWrD0ADXcI"
26+
},
27+
"encryptedKey": "eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjdHkiOiJqd2sranNvbiIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjEwMDAwMCwicDJzIjoiOTFVWjdzRGw3RlNXcldfX1I1NUh3USJ9.FcWtrBDNgrkA33G9Ll9sXh1cPF-3jVXeYe1FLmSDc_Q2PmfLOPvJOA.0ZoN32ayaRWnufJb.WrkffMmDLWiq1-2kn-w7-kVBGW12gjNCBHNHB1hyEdED0rWH1YWpKd8FjoOACdJyLhSn4kAS3Lw5AH7fvO27A48zzvoxZU5EgSm5HG9IjkIH-LBJ-v79ShkpmPylchgjkFhxa5epD11OIK4rFmI7s-0BCjmJokLR_DZBhDMw2khGnsr_MEOfAz9UnqXaQ4MIy8eT52xUpx68gpWFlz2YP3EqiYyNEv0PpjMtyP5lO2i8-p8BqvuJdus9H3fO5Dg-1KVto1wuqh4BQ2JKTauv60QAnM_4sdxRHku3F_nV64SCrZfDvnN2ve21raFROtyXaqHZhN6lyoPxDncy8v4.biaOblEe0N-gMpJyFZ-3-A"
28+
},
29+
{
30+
"name": "[email protected]",
31+
"type": "jwk",
32+
"key": {
33+
"use": "sig",
34+
"kty": "EC",
35+
"kid": "YYNxZ0rq0WsT2MlqLCWvgme3jszkmt99KjoGEJJwAKs",
36+
"crv": "P-256",
37+
"alg": "ES256",
38+
"x": "LsI8nHBflc-mrCbRqhl8d3hSl5sYuSM1AbXBmRfznyg",
39+
"y": "F99LoOvi7z-ZkumsgoHIhodP8q9brXe4bhF3szK-c_w"
40+
},
41+
"encryptedKey": "eyJhbGciOiJQQkVTMi1IUzI1NitBMTI4S1ciLCJjdHkiOiJqd2sranNvbiIsImVuYyI6IkEyNTZHQ00iLCJwMmMiOjEwMDAwMCwicDJzIjoiVERQS2dzcEItTUR4ZDJxTGo0VlpwdyJ9.2_j0cZgTm2eFkZ-hrtr1hBIvLxN0w3TZhbX0Jrrq7vBMaywhgFcGTA.mCasZCbZJ-JT7vjA.bW052WDKSf_ueEXq1dyxLq0n3qXWRO-LXr7OzBLdUKWKSBGQrzqS5KJWqdUCPoMIHTqpwYvm-iD6uFlcxKBYxnsAG_hoq_V3icvvwNQQSd_q7Thxr2_KtPIDJWNuX1t5qXp11hkgb-8d5HO93CmN7xNDG89pzSUepT6RYXOZ483mP5fre9qzkfnrjx3oPROCnf3SnIVUvqk7fwfXuniNsg3NrNqncHYUQNReiq3e9I1R60w0ZQTvIReY7-zfiq7iPgVqmu5I7XGgFK4iBv0L7UOEora65b4hRWeLxg5t7OCfUqrS9yxAk8FdjFb9sEfjopWViPRepB0dYPH8dVI.fb6-7XWqp0j6CR9Li0NI-Q",
42+
"claims": {
43+
"minTLSCertDuration": "60s",
44+
"defaultTLSCertDuration": "120s"
45+
}
46+
}
47+
]
48+
},
49+
"tls": {
50+
"cipherSuites": [
51+
"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
52+
"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
53+
],
54+
"minVersion": 1.2,
55+
"maxVersion": 1.2,
56+
"renegotiation": false
57+
}
58+
}

0 commit comments

Comments
 (0)