Skip to content

Commit

Permalink
Merge pull request #2 from devopscorner/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
zeroc0d3 authored Mar 7, 2023
2 parents c12fe31 + 1234188 commit 758989b
Show file tree
Hide file tree
Showing 5 changed files with 127 additions and 18 deletions.
35 changes: 31 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down
35 changes: 31 additions & 4 deletions Dockerfile.alpine-3.15
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down
35 changes: 31 additions & 4 deletions Dockerfile.alpine-3.16
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down
35 changes: 31 additions & 4 deletions Dockerfile.alpine-3.17
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ networks:
driver: bridge
ipam:
config:
- subnet: 172.148.148.0/16
- subnet: 172.148.0.0/16

#================================================================================================
# VOLUME SETUP
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 758989b

Please sign in to comment.