Skip to content

Commit

Permalink
Merge pull request #112 from cytopia/fixes
Browse files Browse the repository at this point in the history
Enhancement Build
  • Loading branch information
cytopia authored Nov 12, 2022
2 parents e1e8b5f + 890ef83 commit cc6e721
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 76 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/params.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ env:
"NAME": "ansible",
"VERSION": [
"latest",
"2.13",
"2.12",
"2.11",
"2.10",
"2.9",
Expand Down
3 changes: 3 additions & 0 deletions Dockerfiles/Dockerfile-azure
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ RUN set -eux \
coreutils \
g++ \
gcc \
linux-headers \
make \
musl-dev \
openssl-dev \
Expand All @@ -21,6 +22,7 @@ RUN set -eux \
&& pip3 install --no-cache-dir --no-compile \
azure-applicationinsights \
azure-batch \
azure-cli \
azure-cognitiveservices-personalizer \
azure-common \
azure-cosmos \
Expand Down Expand Up @@ -70,6 +72,7 @@ LABEL "org.opencontainers.image.title"="Ansible ${VERSION} azure"
LABEL "org.opencontainers.image.description"="Ansible ${VERSION} azure"

COPY --from=builder /usr/lib/python3.10/site-packages/ /usr/lib/python3.10/site-packages/
COPY --from=builder /usr/bin/az /usr/bin/az

WORKDIR /data
ENTRYPOINT ["/docker-entrypoint.sh"]
Expand Down
29 changes: 22 additions & 7 deletions Dockerfiles/Dockerfile-base
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,31 @@ RUN set -eux \

ARG VERSION
RUN set -eux \
&& MAJOR_VERSION="$( echo "${VERSION}" | awk -F'.' '{print $1}' )" \
&& MINOR_VERSION="$( echo "${VERSION}" | awk -F'.' '{print $2}' )" \
\
&& if [ "${VERSION}" = "latest" ]; then \
pip3 install --no-cache-dir --no-compile ansible; \
elif [ "${VERSION}" = "2.9" ]; then \
pip3 install --no-cache-dir --no-binary pyyaml "ansible>=${VERSION},<2.10"; \
elif [ "${VERSION}" = "2.10" ]; then \
pip3 install --no-cache-dir --no-binary pyyaml "ansible>=${VERSION},<2.11"; \
elif [ "${VERSION}" = "2.11" ]; then \
pip3 install --no-cache-dir --no-binary pyyaml "ansible-core>=${VERSION},<2.12"; \
\
elif [ "${MINOR_VERSION}" -lt "10" ]; then \
pip3 install --no-cache-dir --no-binary pyyaml ansible~=${VERSION}.0; \
\
# Ansible added a weired versioning system with ansible-core and ansible packages:
# https://docs.ansible.com/ansible/devel/reference_appendices/release_and_maintenance.html#ansible-community-changelogs
elif [ "${VERSION}" = "2.10" ]; then\
pip3 install --no-cache-dir --no-binary pyyaml ansible~=3.0; \
\
elif [ "${VERSION}" = "2.11" ]; then\
pip3 install --no-cache-dir --no-binary pyyaml ansible~=4.0; \
\
elif [ "${VERSION}" = "2.12" ]; then\
pip3 install --no-cache-dir --no-binary pyyaml ansible~=5.0; \
\
elif [ "${VERSION}" = "2.13" ]; then\
pip3 install --no-cache-dir --no-binary pyyaml ansible~=6.0; \
\
else \
pip3 install --no-cache-dir --no-binary pyyaml "ansible>=${VERSION},<$(echo "${VERSION}+0.1" | bc)"; \
fail; \
fi \
\
&& if [ "${VERSION}" != "latest" ]; then \
Expand Down
9 changes: 8 additions & 1 deletion Dockerfiles/Dockerfile-infra
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ RUN set -eux \
openssl-dev \
python3-dev \
# misc tools
krb5-dev \
openldap-dev \
postgresql-dev \
postgresql-libs

Expand All @@ -30,8 +32,12 @@ RUN set -eux \
netaddr \
pexpect \
psycopg2 \
pyldap \
pymongo \
pypsexec \
pywinrm \
pywinrm[credssp] \
pywinrm[kerberos] \
smbprotocol \
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf
Expand Down Expand Up @@ -61,7 +67,8 @@ LABEL "org.opencontainers.image.description"="Ansible ${VERSION} infra"
RUN set -eux \
&& apk add --no-cache \
libpq \
rsync
rsync \
sshpass

COPY --from=builder /usr/lib/python3.10/site-packages/ /usr/lib/python3.10/site-packages/

Expand Down
4 changes: 4 additions & 0 deletions Dockerfiles/Dockerfile-tools
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ RUN set -eux \
else \
pip3 install --no-cache-dir --no-compile dnspython mitogen; \
fi \
\
&& pip3 install --no-cache-dir --no-compile \
jmespath \
\
&& find /usr/lib/ -name '__pycache__' -print0 | xargs -0 -n1 rm -rf \
&& find /usr/lib/ -name '*.pyc' -print0 | xargs -0 -n1 rm -rf

Expand Down
54 changes: 29 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Additional Makefiles are pulled from:
# https://github.com/devilbox/makefiles/


ifneq (,)
.error This Makefile requires GNU Make.
endif
Expand Down Expand Up @@ -54,19 +58,19 @@ help:
@echo " Build Targets"
@echo "--------------------------------------------------------------------------------"
@echo
@echo "All Docker images are build as follows: $(IMAGE):\$$VERSION[-\$$STAGEg[\$$KOPS|\$$HELM]]"
@echo "All Docker images are build as follows: $(IMAGE):\$$VERSION[-\$$STAGE[\$$KOPS|\$$HELM]]"
@echo
@echo "build [VERSION=] [ARCH=] [KOPS=] [HELM=] Build Docker image"
@echo "rebuild [VERSION=] [ARCH=] [KOPS=] [HELM=] Build Docker image without cache"
@echo
@echo " make build VERSION=2.3"
@echo " make build VERSION=2.3 STAGEg=tools"
@echo " make build VERSION=2.3 STAGEg=infra"
@echo " make build VERSION=2.3 STAGEg=azure"
@echo " make build VERSION=2.3 STAGEg=aws"
@echo " make build VERSION=2.3 STAGEg=awsk8s"
@echo " make build VERSION=2.3 STAGEg=awshelm HELM=2.11"
@echo " make build VERSION=2.3 STAGEg=awskops KOPS=1.15"
@echo " make build VERSION=2.3 STAGE=tools"
@echo " make build VERSION=2.3 STAGE=infra"
@echo " make build VERSION=2.3 STAGE=azure"
@echo " make build VERSION=2.3 STAGE=aws"
@echo " make build VERSION=2.3 STAGE=awsk8s"
@echo " make build VERSION=2.3 STAGE=awshelm HELM=2.11"
@echo " make build VERSION=2.3 STAGE=awskops KOPS=1.15"
@echo
@echo "--------------------------------------------------------------------------------"
@echo " Test Targets"
Expand All @@ -75,13 +79,13 @@ help:
@echo "test [VERSION=] [ARCH=] [KOPS=] [HELM=] Test built Docker image"
@echo
@echo " make test VERSION=2.3"
@echo " make test VERSION=2.3 STAGEg=tools"
@echo " make test VERSION=2.3 STAGEg=infra"
@echo " make test VERSION=2.3 STAGEg=azure"
@echo " make test VERSION=2.3 STAGEg=aws"
@echo " make test VERSION=2.3 STAGEg=awsk8s"
@echo " make test VERSION=2.3 STAGEg=awshelm HELM=2.11"
@echo " make test VERSION=2.3 STAGEg=awskops KOPS=1.15"
@echo " make test VERSION=2.3 STAGE=tools"
@echo " make test VERSION=2.3 STAGE=infra"
@echo " make test VERSION=2.3 STAGE=azure"
@echo " make test VERSION=2.3 STAGE=aws"
@echo " make test VERSION=2.3 STAGE=awsk8s"
@echo " make test VERSION=2.3 STAGE=awshelm HELM=2.11"
@echo " make test VERSION=2.3 STAGE=awskops KOPS=1.15"
@echo
@echo "--------------------------------------------------------------------------------"
@echo " Tagging Target"
Expand All @@ -90,13 +94,13 @@ help:
@echo "tag [VERSION=] [ARCH=] [KOPS=] [HELM=] [TAG=] Tag built Docker image"
@echo
@echo " make tag VERSION=2.3 TAG=2.3-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=tools TAG=2.3-tools-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=infra TAG=2.3-infra-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=azure TAG=2.3-azure-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=aws TAG=2.3-aws-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=awsk8s TAG=2.3-awsk8s-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=awshelm HELM=2.11 TAG=2.3-awshelm-mysuffix"
@echo " make tag VERSION=2.3 STAGEg=awskops KOPS=1.15 TAG=2.3-awskops-mysuffix"
@echo " make tag VERSION=2.3 STAGE=tools TAG=2.3-tools-mysuffix"
@echo " make tag VERSION=2.3 STAGE=infra TAG=2.3-infra-mysuffix"
@echo " make tag VERSION=2.3 STAGE=azure TAG=2.3-azure-mysuffix"
@echo " make tag VERSION=2.3 STAGE=aws TAG=2.3-aws-mysuffix"
@echo " make tag VERSION=2.3 STAGE=awsk8s TAG=2.3-awsk8s-mysuffix"
@echo " make tag VERSION=2.3 STAGE=awshelm HELM=2.11 TAG=2.3-awshelm-mysuffix"
@echo " make tag VERSION=2.3 STAGE=awskops KOPS=1.15 TAG=2.3-awskops-mysuffix"


# -------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -327,8 +331,8 @@ test-python-libs:
\
\
REQUIRED_BASE="cffi cryptography paramiko Jinja2 PyYAML"; \
REQUIRED_TOOLS="dnspython mitogen"; \
REQUIRED_INFRA="docker docker-compose jsondiff pexpect psycopg2 pypsexec pymongo PyMySQL smbprotocol"; \
REQUIRED_TOOLS="dnspython mitogen jmespath"; \
REQUIRED_INFRA="docker docker-compose jsondiff pexpect psycopg2 pypsexec pymongo PyMySQL smbprotocol pywinrm"; \
REQUIRED_AZURE="azure\-.*"; \
REQUIRED_AWS="awscli botocore boto boto3"; \
REQUIRED_AWSK8S="openshift"; \
Expand Down Expand Up @@ -483,7 +487,7 @@ test-binaries:
REQUIRED_BASE="python"; \
REQUIRED_TOOLS="git gpg jq yq ssh"; \
REQUIRED_INFRA="rsync"; \
REQUIRED_AZURE=""; \
REQUIRED_AZURE="az"; \
REQUIRED_AWS="aws aws-iam-authenticator"; \
REQUIRED_AWSK8S="kubectl oc"; \
REQUIRED_AWSKOPS="kops"; \
Expand Down
Loading

0 comments on commit cc6e721

Please sign in to comment.