diff --git a/src/Dockerfile b/src/Dockerfile index 58c63a3..940cadf 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -1,16 +1,8 @@ -FROM python:3.10-alpine +FROM rbrandstaedter/solarflow-control-baseimage:latest # Create stdconfig directory WORKDIR / COPY solarflow-control.py / -# dependencies needed for ARMv6/7 builds -RUN pip install --upgrade pip && \ - apk add libxml2-dev libxslt-dev libffi libffi-dev gcc musl-dev rust cargo openssl-dev && \ - pip install paho-mqtt astral ip2geotools && \ - apk del openssl-dev libffi-dev xz-dev libxml2-dev libxslt-dev openssl-dev linux-headers musl-dev gcc rust cargo && \ - rm -rf /root/.cache/ && \ - rm -rf /var/cache/apk/* - ENTRYPOINT ["python","solarflow-control.py"] diff --git a/src/Dockerfile-baseimage b/src/Dockerfile-baseimage new file mode 100644 index 0000000..46ded90 --- /dev/null +++ b/src/Dockerfile-baseimage @@ -0,0 +1,14 @@ +FROM python:3.10-alpine + +# Create stdconfig directory +WORKDIR / + +# dependencies needed for ARMv6/7 builds +RUN pip install --upgrade pip && \ + apk add libxml2-dev libxslt-dev libffi libffi-dev gcc musl-dev rust cargo openssl-dev && \ + pip install paho-mqtt astral ip2geotools && \ + apk del openssl-dev libffi-dev xz-dev libxml2-dev libxslt-dev openssl-dev linux-headers musl-dev gcc rust cargo && \ + rm -rf /root/.cache/ && \ + rm -rf /var/cache/apk/* + +ENTRYPOINT ["python"] diff --git a/src/Jenkinsfile-baseimage b/src/Jenkinsfile-baseimage new file mode 100644 index 0000000..f62b06e --- /dev/null +++ b/src/Jenkinsfile-baseimage @@ -0,0 +1,35 @@ +pipeline { + agent { label 'docker-builder' } + + environment { + DOCKER_HOST = "tcp://docker.local:2375" + DOCKER_REGISTRY = "rbrandstaedter" + LOG_LEVEL = "INFO" + BUILD_NUMBER = "${BUILD_NUMBER}" + TAG = "0.${BUILD_NUMBER}" + DOCKERHUB_LOGIN = credentials('docker-login-private') + GITHUB_AUTH_TOKEN = credentials('github_auth_token') + git_branch = "${GIT_BRANCH}" + BRANCH_NAME = git_branch.substring(git_branch.lastIndexOf('/') + 1, git_branch.length()) + } + + stages { + stage('Build Docker Base Images') { + steps { + sh 'printenv' + dir("${env.WORKSPACE}/src"){ + sh label: 'Set up X-Builder', script: 'docker buildx rm crossbuilder && docker buildx create --name crossbuilder --platform linux/amd64,linux/arm/v6 && docker buildx ls && docker buildx use crossbuilder && docker buildx inspect --bootstrap' + sh label: 'Build Base Image', script: 'docker -H ${DOCKER_HOST} buildx build --push --platform linux/amd64,linux/arm/v6 -t ${DOCKER_REGISTRY}/solarflow-control-baseimage:latest -f Dockerfile-baseimage .' + } + } + } + } + post { + always { + cleanWs(cleanWhenNotBuilt: false, + deleteDirs: true, + disableDeferredWipeout: true, + notFailBuild: true) + } + } +} \ No newline at end of file