From 1a4ed66e7d53f8303e9babfd7ffd17b108cb7611 Mon Sep 17 00:00:00 2001 From: Severin Neumann Date: Tue, 7 Jan 2025 11:58:15 +0100 Subject: [PATCH] add images for generators (#81) --- .github/workflows/build-images-on-commit.yml | 2 ++ .github/workflows/build-images-on-pr.yml | 2 ++ .../reusable-build-container-images.yml | 4 ++++ scripts/build.sh | 9 ++++++++ scripts/generators/docker-compose/Dockerfile | 2 +- scripts/generators/k8s/Dockerfile | 21 +++++++++++++++++++ 6 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 scripts/generators/k8s/Dockerfile diff --git a/.github/workflows/build-images-on-commit.yml b/.github/workflows/build-images-on-commit.yml index 7c9c62e..b2d6a30 100644 --- a/.github/workflows/build-images-on-commit.yml +++ b/.github/workflows/build-images-on-commit.yml @@ -7,6 +7,8 @@ on: - "src/loaders/**" - "src/services/**" - "src/databases/**" + - "scripts/docker-compose/**" + - "scripts/k8s/**" - ".github/workflows/reusable-build-container-images.yml" - ".github/workflows/build-images-on-commit.yml" workflow_dispatch: diff --git a/.github/workflows/build-images-on-pr.yml b/.github/workflows/build-images-on-pr.yml index 4a0b2b4..679423a 100644 --- a/.github/workflows/build-images-on-pr.yml +++ b/.github/workflows/build-images-on-pr.yml @@ -6,6 +6,8 @@ on: - "src/loaders/**" - "src/services/**" - "src/databases/**" + - "scripts/docker-compose/**" + - "scripts/k8s/**" - ".github/workflows/reusable-build-container-images.yml" - ".github/workflows/check.yml" diff --git a/.github/workflows/reusable-build-container-images.yml b/.github/workflows/reusable-build-container-images.yml index 6820c95..521ac0a 100644 --- a/.github/workflows/reusable-build-container-images.yml +++ b/.github/workflows/reusable-build-container-images.yml @@ -31,6 +31,10 @@ jobs: name: services-nodejs - context: ./src/databases/mysql name: databases-mysql + - context: ./scripts/docker-compose + name: generators-docker-compose + - context: ./scripts/k8s + name: generators-k8s steps: - name: Checkout uses: actions/checkout@v4.2.2 diff --git a/scripts/build.sh b/scripts/build.sh index 4920aec..f8b4092 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -73,3 +73,12 @@ for DIR in "${REPO_DIR}/src/loaders"/*; do docker buildx build --platform "$PLATFORM" -t "$IMAGE_TAG" $PUSH "$DIR" $PUSH fi done + +for DIR in "${REPO_DIR}/scripts/generators"/*; do + if [ -d "$DIR" ]; then + IMAGE_TAG="${REPO_PREFIX}/${IMAGE_PREFIX}-generators-$(basename "$DIR"):$VERSION" + echo "Building $IMAGE_TAG..." + echo "Running 'docker buildx build --platform $PLATFORM -t $IMAGE_TAG $DIR $PUSH'" + docker buildx build --platform "$PLATFORM" -t "$IMAGE_TAG" $PUSH "$DIR" $PUSH + fi +done \ No newline at end of file diff --git a/scripts/generators/docker-compose/Dockerfile b/scripts/generators/docker-compose/Dockerfile index c888c7c..245725b 100644 --- a/scripts/generators/docker-compose/Dockerfile +++ b/scripts/generators/docker-compose/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.14-alpine +FROM python:3.13-alpine WORKDIR /app diff --git a/scripts/generators/k8s/Dockerfile b/scripts/generators/k8s/Dockerfile new file mode 100644 index 0000000..f8a8df4 --- /dev/null +++ b/scripts/generators/k8s/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.13-alpine + +WORKDIR /app + +RUN apk addgroup -S appgroup && adduser -S appuser -G appgroup + +COPY requirements.txt . +RUN pip install --no-cache-dir -r requirements.txt + +COPY createManifests.py . + +COPY templates ./templates +COPY deployments ./deployments + +RUN chown -R appuser:appgroup /app && chmod +x createManifests.py +USER appuser + +VOLUME [ "/app/deployments" ] + +# Define the default entrypoint to run the script +ENTRYPOINT ["python", "createManifests.py"]