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>
This commit is contained in:
14
.travis.yml
14
.travis.yml
@@ -18,17 +18,25 @@ after_success:
|
||||
export DOCKER_NS=openfaas;
|
||||
fi;
|
||||
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev $DOCKER_NS/faas-cli:$TRAVIS_TAG;
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev $DOCKER_NS/faas-cli:latest;
|
||||
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_USERNAME --password-stdin;
|
||||
docker tag openfaas/faas-cli:latest-dev $DOCKER_NS/faas-cli:$TRAVIS_TAG;
|
||||
docker tag openfaas/faas-cli:latest-dev $DOCKER_NS/faas-cli:latest;
|
||||
docker tag openfaas/faas-cli:latest-dev-root $DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
|
||||
docker tag openfaas/faas-cli:latest-dev-root $DOCKER_NS/faas-cli:latest-root;
|
||||
echo $DOCKER_PASSWORD | docker login -u=$DOCKER_NS --password-stdin;
|
||||
docker push $DOCKER_NS/faas-cli:$TRAVIS_TAG;
|
||||
docker push $DOCKER_NS/faas-cli:latest;
|
||||
docker push $DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
|
||||
docker push $DOCKER_NS/faas-cli:latest-root;
|
||||
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev quay.io/$DOCKER_NS/faas-cli:$TRAVIS_TAG;
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev quay.io/$DOCKER_NS/faas-cli:latest;
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev-root quay.io/$DOCKER_NS/faas-cli:${TRAVIS_TAG}latest-root;
|
||||
docker tag $DOCKER_NS/faas-cli:latest-dev-root quay.io/$DOCKER_NS/faas-cli:latest-root;
|
||||
echo $QUAY_PASSWORD | docker login -u=$QUAY_USERNAME --password-stdin quay.io;
|
||||
docker push quay.io/$DOCKER_NS/faas-cli:$TRAVIS_TAG;
|
||||
docker push quay.io/$DOCKER_NS/faas-cli:latest;
|
||||
docker push quay.io/$DOCKER_NS/faas-cli:${TRAVIS_TAG}-root;
|
||||
docker push quay.io/$DOCKER_NS/faas-cli:latest-root;
|
||||
|
||||
fi;
|
||||
|
||||
|
||||
17
Dockerfile
17
Dockerfile
@@ -30,6 +30,21 @@ RUN VERSION=$(git describe --all --exact-match `git rev-parse HEAD` | grep tags
|
||||
-X github.com/openfaas/faas-cli/commands.Platform=x86_64" \
|
||||
-a -installsuffix cgo -o faas-cli
|
||||
|
||||
|
||||
# CICD stage
|
||||
FROM alpine:3.11 as root
|
||||
|
||||
RUN apk --no-cache add ca-certificates git
|
||||
|
||||
WORKDIR /home/app
|
||||
|
||||
COPY --from=builder /go/src/github.com/openfaas/faas-cli/faas-cli /usr/bin/
|
||||
|
||||
ENV PATH=$PATH:/usr/bin/
|
||||
|
||||
ENTRYPOINT [ "faas-cli" ]
|
||||
|
||||
|
||||
# Release stage
|
||||
FROM alpine:3.11 as release
|
||||
|
||||
@@ -48,4 +63,4 @@ USER app
|
||||
|
||||
ENV PATH=$PATH:/usr/bin/
|
||||
|
||||
CMD ["faas-cli"]
|
||||
ENTRYPOINT ["faas-cli"]
|
||||
4
Makefile
4
Makefile
@@ -41,7 +41,7 @@ test-unit:
|
||||
|
||||
.PHONY: ci-armhf-push
|
||||
ci-armhf-push:
|
||||
(docker push openfaas/faas-cli:$(TAG)-armhf)
|
||||
(docker push openfaas/faas-cli:$(TAG)-armhf && docker push openfaas/faas-cli:$(TAG)-root-armhf)
|
||||
|
||||
.PHONY: ci-armhf-build
|
||||
ci-armhf-build:
|
||||
@@ -49,7 +49,7 @@ ci-armhf-build:
|
||||
|
||||
.PHONY: ci-arm64-push
|
||||
ci-arm64-push:
|
||||
(docker push openfaas/faas-cli:$(TAG)-arm64)
|
||||
(docker push openfaas/faas-cli:$(TAG)-arm64 && docker push openfaas/faas-cli:$(TAG)-root-arm64)
|
||||
|
||||
.PHONY: ci-arm64-build
|
||||
ci-arm64-build:
|
||||
|
||||
6
build.sh
6
build.sh
@@ -8,7 +8,11 @@ fi
|
||||
|
||||
echo Building openfaas/faas-cli:$eTAG
|
||||
|
||||
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -t openfaas/faas-cli:$eTAG .
|
||||
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --target release -t openfaas/faas-cli:$eTAG .
|
||||
|
||||
echo Building openfaas/faas-cli:$eTAG-root
|
||||
|
||||
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy --target root -t openfaas/faas-cli:$eTAG-root .
|
||||
|
||||
if [ $? == 0 ] ; then
|
||||
|
||||
|
||||
Reference in New Issue
Block a user