-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from navilg/21-k8senv-build-a-docker-image-for…
…-k8senv-to-use-make-it-usable-in-any-cicd-pipeline Docker image for k8senv
- Loading branch information
Showing
3 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
FROM golang:1.20.3-alpine3.17 as build | ||
ARG OS | ||
ARG ARCH | ||
WORKDIR /build | ||
COPY . . | ||
RUN apk add git | ||
RUN go mod download && \ | ||
CGO_ENABLED=0 go build -o k8senv | ||
|
||
FROM alpine:3.17 | ||
ARG VERSION | ||
ARG user=k8senv | ||
ARG group=k8senv | ||
ARG uid=1000 | ||
ARG gid=1000 | ||
USER root | ||
WORKDIR /app | ||
COPY --from=build /build/k8senv /app/.k8senv/bin/k8senv | ||
RUN apk update && apk --no-cache add bash vim && addgroup -g ${gid} ${group} && adduser -h /app -u ${uid} -G ${group} -s /bin/bash -D ${user} | ||
RUN chown -R k8senv:k8senv /app/.k8senv && chmod -R u+rx /app/.k8senv | ||
USER k8senv | ||
ENV PATH="/app/.k8senv/bin:$PATH" | ||
VOLUME /app/.k8senv/ | ||
ENTRYPOINT [ "k8senv"] | ||
CMD ["help"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Docker image | ||
|
||
version=$(go run main.go version | cut -d " " -f 2 | jq .K8senv | tr -d "\"") | ||
docker buildx create --name dockerxbuilder --use --bootstrap | ||
|
||
if [ "$1" == "push" ]; then | ||
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 --tag linuxshots/k8senv:$version . | ||
docker buildx build --push --platform linux/amd64,linux/arm64,linux/arm/v7 --tag linuxshots/k8senv . | ||
else | ||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --tag linuxshots/k8senv:$version . | ||
docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 --tag linuxshots/k8senv . | ||
fi |