better structuring to docker image building

This commit is contained in:
Mirco 2023-12-15 16:11:49 +01:00
parent bfc55293dc
commit 2914be8a88
15 changed files with 80 additions and 21 deletions

View file

@ -1,4 +1,4 @@
FROM node:lts-bookworm-slim FROM node:lts-bookworm-slim
ADD resources /tmp ADD resources /tmp
RUN DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes /tmp/install.sh RUN /tmp/install.sh

View file

@ -45,4 +45,4 @@ function checksum() {
} }
source /tmp/install_functions.sh source /tmp/install_functions.sh
main DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main

View file

@ -1,6 +1,6 @@
FROM debian:stable-slim FROM debian:stable-slim
ADD resources /tmp ADD resources /tmp
RUN DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes /tmp/install.sh RUN /tmp/install.sh
ENV LANG=en_US.UTF-8 \ ENV LANG=en_US.UTF-8 \
JAVA_HOME=/usr/lib64/graalvm/graalvm-community-java17 JAVA_HOME=/usr/lib64/graalvm/graalvm-community-java17

View file

@ -55,4 +55,4 @@ function checksum() {
} }
source /tmp/install_functions.sh source /tmp/install_functions.sh
main DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main

View file

@ -1,5 +1,5 @@
FROM python:3.10-alpine FROM python:3.10-alpine
WORKDIR /tmp ADD resources /tmp
ADD resources ./
RUN ./install.sh RUN /tmp/install.sh

View file

@ -4,14 +4,16 @@ set -exo pipefail
function main() { function main() {
{ {
#upgradeSystem
apk -U upgrade apk -U upgrade
apk add --no-cache python3 py3-pip openssl-dev bash git curl apk add --no-cache python3 py3-pip openssl-dev bash git curl
python3 -m pip install -U pip python3 -m pip install -U pip
pip3 install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection pip3 install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection
#cleanupDocker
apk cache clean apk cache clean
} > /dev/null
rm -rf /tmp/* rm -rf /tmp/*
} > /dev/null
} }
#source /tmp/install_functions_alpine.sh
main main

View file

@ -4,14 +4,15 @@ set -exo pipefail
function main() { function main() {
{ {
#upgradeSystem
apk -U upgrade apk -U upgrade
apk add --no-cache python3 py3-pip openssl-dev bash git apk add --no-cache python3 py3-pip openssl-dev bash git
python3 -m pip install -U pip pip3 --break-system-packages install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection
pip3 install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection #cleanupDocker
apk cache clean apk cache clean
} > /dev/null
rm -rf /tmp/* rm -rf /tmp/*
} > /dev/null
} }
#source /tmp/install_functions_alpine.sh
main main

View file

@ -1,4 +1,4 @@
FROM debian:stable-slim FROM debian:stable-slim
ADD resources /tmp ADD resources /tmp
RUN DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes /tmp/install.sh RUN /tmp/install.sh

View file

@ -7,11 +7,11 @@ function main() {
apt-get -qqy install curl git kotlin gradle iputils-ping ssh python3 python3-pip apt-get -qqy install curl git kotlin gradle iputils-ping ssh python3 python3-pip
pip3 install pybuilder 'ddadevops>=4.7.0' deprecation dda-python-terraform boto3 pyyaml inflection --break-system-packages pip3 install --break-system-packages pybuilder 'ddadevops>=4.7.0' deprecation dda-python-terraform boto3 pyyaml inflection
cleanupDocker cleanupDocker
} > /dev/null } > /dev/null
} }
source /tmp/install_functions.sh source /tmp/install_functions.sh
main DEBIAN_FRONTEND=noninteractive DEBCONF_NOWARNINGS=yes main

View file

@ -1,5 +1,4 @@
FROM python:3.10-alpine FROM python:3.10-alpine
WORKDIR /tmp ADD resources /tmp
ADD resources ./ RUN /tmp/install.sh
RUN ./install.sh

View file

@ -4,15 +4,17 @@ set -exo pipefail
function main() { function main() {
{ {
#upgradeSystem
apk -U upgrade apk -U upgrade
apk add --no-cache build-base rust python3 python3-dev py3-pip py3-setuptools py3-wheel libffi-dev openssl-dev cargo bash git curl apk add --no-cache build-base rust python3 python3-dev py3-pip py3-setuptools py3-wheel libffi-dev openssl-dev cargo bash git curl
python3 -m pip install -U pip python3 -m pip install -U pip
pip3 install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection \ pip3 install pybuilder ddadevops deprecation dda-python-terraform boto3 pyyaml inflection \
coverage flake8 flake8-polyfill mypy mypy-extensions pycodestyle pyflakes pylint pytest pytest-cov pytest-datafiles types-setuptools types-PyYAML coverage flake8 flake8-polyfill mypy mypy-extensions pycodestyle pyflakes pylint pytest pytest-cov pytest-datafiles types-setuptools types-PyYAML
#cleanupDocker
apk cache clean apk cache clean
} > /dev/null
rm -rf /tmp/* rm -rf /tmp/*
} > /dev/null
} }
#source /tmp/install_functions_alpine.sh
main main

View file

@ -31,6 +31,12 @@ class ImageBuildService:
self.__copy_build_resource_file_from_package__( self.__copy_build_resource_file_from_package__(
"image/resources/install_functions.sh", devops "image/resources/install_functions.sh", devops
) )
self.__copy_build_resource_file_from_package__(
"image/resources/install_functions_debian.sh", devops
)
self.__copy_build_resource_file_from_package__(
"image/resources/install_functions_alpine.sh", devops
)
def __copy_build_resources_from_dir__(self, devops: Devops): def __copy_build_resources_from_dir__(self, devops: Devops):
image = devops.specialized_builds[BuildType.IMAGE] image = devops.specialized_builds[BuildType.IMAGE]

View file

@ -1,3 +1,6 @@
#
#deprecated, we recommend to use install_functions_debian.sh instead. We will going to remove install_functions.sh in a future release.
#
function upgradeSystem() { function upgradeSystem() {
{ {
apt-get update apt-get update

View file

@ -0,0 +1,21 @@
function upgradeSystem() {
apk -U upgrade
}
function cleanupDocker() {
rm -f /root/.ssh/authorized_keys
rm -f /root/.ssh/authorized_keys2
apk cache clean
rm -rf /tmp/*
find /var/cache -type f -exec rm -rf {} \;
find /var/log/ -name '*.log' -exec rm -f {} \;
}
function cleanupAmi() {
rm -f /home/ubuntu/.ssh/authorized_keys
rm -f /home/ubuntu/.ssh/authorized_keys2
cleanupDocker
}

View file

@ -0,0 +1,25 @@
function upgradeSystem() {
apt-get update
apt-get -qqy upgrade
}
function cleanupDocker() {
rm -f /root/.ssh/authorized_keys
rm -f /root/.ssh/authorized_keys2
apt-get clean
apt-get -qqy autoremove --purge
apt-get -qqy autoclean
rm -rf /var/lib/apt/lists/
rm -rf /tmp/*
find /var/cache -type f -exec rm -rf {} \;
find /var/log/ -name '*.log' -exec rm -f {} \;
}
function cleanupAmi() {
rm -f /home/ubuntu/.ssh/authorized_keys
rm -f /home/ubuntu/.ssh/authorized_keys2
cleanupDocker
}