Skip to content

Commit 372d120

Browse files
utsavanand2alexellis
authored andcommitted
Add root user for faas-cli invokation
Adds a new target stage for faas-cli's Docker image having a root user that can be used with CI/CD environments like Google Cloud Build. Also add a [Breaking Change] that switches from using `CMD` in the Dockerfile to `ENTRYPOINT` which allows overriding commands in CI/CD environments. Signed-off-by: Utsav Anand <utsavanand2@gmail.com>
1 parent 9ac49b3 commit 372d120

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

.travis.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,25 @@ after_success:
1818
export DOCKER_NS=openfaas;
1919
fi;
2020

21-
docker tag $DOCKER_NS/faas-cli:latest-dev $DOCKER_NS/faas-cli:$TRAVIS_TAG;
22-
docker tag $DOCKER_NS/faas-cli:latest-dev $DOCKER_NS/faas-cli:latest;
23-
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
21+
docker tag openfaas/faas-cli:latest-dev $DOCKER_NS/faas-cli:$TRAVIS_TAG;
22+
docker tag openfaas/faas-cli:latest-dev $DOCKER_NS/faas-cli:latest;
23+
docker tag openfaas/faas-cli:latest-dev-root $DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
24+
docker tag openfaas/faas-cli:latest-dev-root $DOCKER_NS/faas-cli:latest-root;
25+
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_NS --password-stdin;
2426
docker push $DOCKER_NS/faas-cli:$TRAVIS_TAG;
2527
docker push $DOCKER_NS/faas-cli:latest;
28+
docker push $DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
29+
docker push $DOCKER_NS/faas-cli:latest-root;
2630

2731
docker tag $DOCKER_NS/faas-cli:latest-dev quay.io/$DOCKER_NS/faas-cli:$TRAVIS_TAG;
2832
docker tag $DOCKER_NS/faas-cli:latest-dev quay.io/$DOCKER_NS/faas-cli:latest;
33+
docker tag $DOCKER_NS/faas-cli:latest-dev-root quay.io/$DOCKER_NS/faas-cli:${TRAVIS_TAG}latest-root;
34+
docker tag $DOCKER_NS/faas-cli:latest-dev-root quay.io/$DOCKER_NS/faas-cli:latest-root;
2935
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
3036
docker push quay.io/$DOCKER_NS/faas-cli:$TRAVIS_TAG;
3137
docker push quay.io/$DOCKER_NS/faas-cli:latest;
38+
docker push quay.io/$DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
39+
docker push quay.io/$DOCKER_NS/faas-cli:latest-root;
3240

3341
fi;
3442

Dockerfile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags
3030
-X github.com/openfaas/faas-cli/commands.Platform=x86_64" \
3131
-a -installsuffix cgo -o faas-cli
3232

33+
34+
# CICD stage
35+
FROM alpine:3.11 as root
36+
37+
RUN apk --no-cache add ca-certificates git
38+
39+
WORKDIR /home/app
40+
41+
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli /usr/bin/
42+
43+
ENV PATH=$PATH:/usr/bin/
44+
45+
ENTRYPOINT [ "faas-cli" ]
46+
47+
3348
# Release stage
3449
FROM alpine:3.11 as release
3550

@@ -48,4 +63,4 @@ USER app
4863

4964
ENV PATH=$PATH:/usr/bin/
5065

51-
CMD ["faas-cli"]
66+
ENTRYPOINT ["faas-cli"]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ test-unit:
4141

4242
.PHONY: ci-armhf-push
4343
ci-armhf-push:
44-
(docker push openfaas/faas-cli:$(TAG)-armhf)
44+
(docker push openfaas/faas-cli:$(TAG)-armhf && docker push openfaas/faas-cli:$(TAG)-root-armhf)
4545

4646
.PHONY: ci-armhf-build
4747
ci-armhf-build:
4848
(./build.sh $(TAG)-armhf)
4949

5050
.PHONY: ci-arm64-push
5151
ci-arm64-push:
52-
(docker push openfaas/faas-cli:$(TAG)-arm64)
52+
(docker push openfaas/faas-cli:$(TAG)-arm64 && docker push openfaas/faas-cli:$(TAG)-root-arm64)
5353

5454
.PHONY: ci-arm64-build
5555
ci-arm64-build:

build.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ fi
88

99
echo Building openfaas/faas-cli:$eTAG
1010

11-
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t openfaas/faas-cli:$eTAG .
11+
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --target release -t openfaas/faas-cli:$eTAG .
12+
13+
echo Building openfaas/faas-cli:$eTAG-root
14+
15+
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --target root -t openfaas/faas-cli:$eTAG-root .
1216

1317
if [ $? == 0 ] ; then
1418

0 commit comments

Comments
 (0)