diff --git a/Dockerfile b/Dockerfile index 13a22bf..81501df 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -### Builder ### -FROM golang:1.19.5-alpine3.17 as builder +### Builder Go ### +FROM golang:1.19.5-alpine3.17 as builder-go WORKDIR /go/src/app ENV GIN_MODE=release @@ -18,6 +18,31 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ cd /go/src/app && \ go build -mod=readonly -ldflags="-s -w" -o goapp + +### Builder Python ### +FROM python:3.10.10-alpine${ALPINE_VERSION:-3.17} as builder-python + +ARG AWS_CLI_VERSION=2.11.0 +RUN apk add --no-cache git unzip groff build-base libffi-dev cmake +RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git + +WORKDIR aws-cli +RUN python -m venv venv +RUN . venv/bin/activate +RUN scripts/installers/make-exe +RUN unzip -q dist/awscli-exe.zip +RUN aws/install --bin-dir /aws-cli-bin +RUN /aws-cli-bin/aws --version + +# reduce image size: remove autocomplete and examples +RUN rm -rf \ + /usr/local/aws-cli/v2/current/dist/aws_completer \ + /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \ + /usr/local/aws-cli/v2/current/dist/awscli/examples +RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete +RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete + + ### Binary ### # FROM golang:1.19.5-alpine3.17 FROM nginx:${NGINX_VERSION:-1.23-alpine} @@ -59,8 +84,10 @@ LABEL maintainer="$AUTHOR" \ fr.hbis.docker.base.version="$BUILD_VERSION" ENV GIN_MODE=release -COPY --from=devopscorner/cicd:alpine /usr/local/bin/ /usr/local/bin/ -COPY --from=builder /go/src/app/goapp /usr/local/bin/k8s-context +COPY --from=alpine/k8s:1.26.2 /usr/bin/ /usr/local/bin/ +COPY --from=builder-python /usr/local/aws-cli/ /usr/local/aws-cli/ +COPY --from=builder-python /aws-cli-bin/ /usr/local/bin/ +COPY --from=builder-go /go/src/app/goapp /usr/local/bin/k8s-context EXPOSE 22 80 443 diff --git a/Dockerfile.alpine-3.15 b/Dockerfile.alpine-3.15 index 08b1ec7..8b11d30 100644 --- a/Dockerfile.alpine-3.15 +++ b/Dockerfile.alpine-3.15 @@ -1,5 +1,5 @@ -### Builder ### -FROM golang:1.19.3-alpine3.15 as builder +### Builder Go ### +FROM golang:1.19.3-alpine3.15 as builder-go WORKDIR /go/src/app ENV GIN_MODE=release @@ -18,6 +18,31 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ cd /go/src/app && \ go build -mod=readonly -ldflags="-s -w" -o goapp + +### Builder Python ### +FROM python:3.10.10-alpine${ALPINE_VERSION:-3.16} as builder-python + +ARG AWS_CLI_VERSION=2.11.0 +RUN apk add --no-cache git unzip groff build-base libffi-dev cmake +RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git + +WORKDIR aws-cli +RUN python -m venv venv +RUN . venv/bin/activate +RUN scripts/installers/make-exe +RUN unzip -q dist/awscli-exe.zip +RUN aws/install --bin-dir /aws-cli-bin +RUN /aws-cli-bin/aws --version + +# reduce image size: remove autocomplete and examples +RUN rm -rf \ + /usr/local/aws-cli/v2/current/dist/aws_completer \ + /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \ + /usr/local/aws-cli/v2/current/dist/awscli/examples +RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete +RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete + + ### Binary ### # FROM golang:1.19.3-alpine3.15 FROM nginx:${NGINX_VERSION:-1.23-alpine} @@ -59,8 +84,10 @@ LABEL maintainer="$AUTHOR" \ fr.hbis.docker.base.version="$BUILD_VERSION" ENV GIN_MODE=release -COPY --from=devopscorner/cicd:alpine /usr/local/bin/ /usr/local/bin/ -COPY --from=builder /go/src/app/goapp /usr/local/bin/k8s-context +COPY --from=alpine/k8s:1.26.2 /usr/bin/ /usr/local/bin/ +COPY --from=builder-python /usr/local/aws-cli/ /usr/local/aws-cli/ +COPY --from=builder-python /aws-cli-bin/ /usr/local/bin/ +COPY --from=builder-go /go/src/app/goapp /usr/local/bin/k8s-context EXPOSE 22 80 443 diff --git a/Dockerfile.alpine-3.16 b/Dockerfile.alpine-3.16 index 15b4dbb..73d845c 100644 --- a/Dockerfile.alpine-3.16 +++ b/Dockerfile.alpine-3.16 @@ -1,5 +1,5 @@ -### Builder ### -FROM golang:1.19.5-alpine3.16 as builder +### Builder Go ### +FROM golang:1.19.5-alpine3.16 as builder-go WORKDIR /go/src/app ENV GIN_MODE=release @@ -18,6 +18,31 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ cd /go/src/app && \ go build -mod=readonly -ldflags="-s -w" -o goapp + +### Builder Python ### +FROM python:3.10.10-alpine${ALPINE_VERSION:-3.16} as builder-python + +ARG AWS_CLI_VERSION=2.11.0 +RUN apk add --no-cache git unzip groff build-base libffi-dev cmake +RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git + +WORKDIR aws-cli +RUN python -m venv venv +RUN . venv/bin/activate +RUN scripts/installers/make-exe +RUN unzip -q dist/awscli-exe.zip +RUN aws/install --bin-dir /aws-cli-bin +RUN /aws-cli-bin/aws --version + +# reduce image size: remove autocomplete and examples +RUN rm -rf \ + /usr/local/aws-cli/v2/current/dist/aws_completer \ + /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \ + /usr/local/aws-cli/v2/current/dist/awscli/examples +RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete +RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete + + ### Binary ### # FROM golang:1.19.5-alpine3.16 FROM nginx:${NGINX_VERSION:-1.23-alpine} @@ -59,8 +84,10 @@ LABEL maintainer="$AUTHOR" \ fr.hbis.docker.base.version="$BUILD_VERSION" ENV GIN_MODE=release -COPY --from=devopscorner/cicd:alpine /usr/local/bin/ /usr/local/bin/ -COPY --from=builder /go/src/app/goapp /usr/local/bin/k8s-context +COPY --from=alpine/k8s:1.26.2 /usr/bin/ /usr/local/bin/ +COPY --from=builder-python /usr/local/aws-cli/ /usr/local/aws-cli/ +COPY --from=builder-python /aws-cli-bin/ /usr/local/bin/ +COPY --from=builder-go /go/src/app/goapp /usr/local/bin/k8s-context EXPOSE 22 80 443 diff --git a/Dockerfile.alpine-3.17 b/Dockerfile.alpine-3.17 index 13a22bf..81501df 100644 --- a/Dockerfile.alpine-3.17 +++ b/Dockerfile.alpine-3.17 @@ -1,5 +1,5 @@ -### Builder ### -FROM golang:1.19.5-alpine3.17 as builder +### Builder Go ### +FROM golang:1.19.5-alpine3.17 as builder-go WORKDIR /go/src/app ENV GIN_MODE=release @@ -18,6 +18,31 @@ RUN GOOS=linux GOARCH=amd64 CGO_ENABLED=0 \ cd /go/src/app && \ go build -mod=readonly -ldflags="-s -w" -o goapp + +### Builder Python ### +FROM python:3.10.10-alpine${ALPINE_VERSION:-3.17} as builder-python + +ARG AWS_CLI_VERSION=2.11.0 +RUN apk add --no-cache git unzip groff build-base libffi-dev cmake +RUN git clone --single-branch --depth 1 -b ${AWS_CLI_VERSION} https://github.com/aws/aws-cli.git + +WORKDIR aws-cli +RUN python -m venv venv +RUN . venv/bin/activate +RUN scripts/installers/make-exe +RUN unzip -q dist/awscli-exe.zip +RUN aws/install --bin-dir /aws-cli-bin +RUN /aws-cli-bin/aws --version + +# reduce image size: remove autocomplete and examples +RUN rm -rf \ + /usr/local/aws-cli/v2/current/dist/aws_completer \ + /usr/local/aws-cli/v2/current/dist/awscli/data/ac.index \ + /usr/local/aws-cli/v2/current/dist/awscli/examples +RUN find /usr/local/aws-cli/v2/current/dist/awscli/data -name completions-1*.json -delete +RUN find /usr/local/aws-cli/v2/current/dist/awscli/botocore/data -name examples-1.json -delete + + ### Binary ### # FROM golang:1.19.5-alpine3.17 FROM nginx:${NGINX_VERSION:-1.23-alpine} @@ -59,8 +84,10 @@ LABEL maintainer="$AUTHOR" \ fr.hbis.docker.base.version="$BUILD_VERSION" ENV GIN_MODE=release -COPY --from=devopscorner/cicd:alpine /usr/local/bin/ /usr/local/bin/ -COPY --from=builder /go/src/app/goapp /usr/local/bin/k8s-context +COPY --from=alpine/k8s:1.26.2 /usr/bin/ /usr/local/bin/ +COPY --from=builder-python /usr/local/aws-cli/ /usr/local/aws-cli/ +COPY --from=builder-python /aws-cli-bin/ /usr/local/bin/ +COPY --from=builder-go /go/src/app/goapp /usr/local/bin/k8s-context EXPOSE 22 80 443 diff --git a/docker-compose.yml b/docker-compose.yml index 49caa1b..3ea9889 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -9,7 +9,7 @@ networks: driver: bridge ipam: config: - - subnet: 172.148.148.0/16 + - subnet: 172.148.0.0/16 #================================================================================================ # VOLUME SETUP @@ -57,10 +57,11 @@ services: build: context: . dockerfile: Dockerfile + # image: devopscorner/k8s-context:alpine container_name: ${CONTAINER_K8S_CONTEXT:-devopscorner_k8s_context} restart: unless-stopped ports: - - "${PORT_K8S_CONTEXT:-8080}:8080" + - "${PORT_K8S_CONTEXT:-8080}:80" volumes: # - /etc/localtime:/etc/localtime:ro ## Do not use it in mac - /var/run/docker.sock:/var/run/docker.sock ## Do not use it in k8s