Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/344 add certificates to consumers #345

Merged
merged 6 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ PG_VERSION=11.9.8
DRACON_NS=dracon
TEKTON_NS=tekton-pipelines
ARANGODB_NS=arangodb
BASE_IMAGE=scratch

DOCKER=docker
PROTOC=protoc
Expand Down
7 changes: 0 additions & 7 deletions components/consumers/dependency-track/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions components/consumers/dependency-track/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions components/consumers/jira/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions components/consumers/jira/Makefile

This file was deleted.

7 changes: 0 additions & 7 deletions components/consumers/slack/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions components/consumers/slack/Makefile

This file was deleted.

6 changes: 0 additions & 6 deletions components/producers/aggregator/Dockerfile

This file was deleted.

8 changes: 4 additions & 4 deletions components/producers/aggregator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
CONTAINER_REPO=
DRACON_VERSION=
SOURCE_CODE_REPO=
PRODUCER_AGGREGATOR_BASE_IMAGE=$(shell test -e .custom_image && cat .custom_image || echo "scratch")

DOCKER=docker

container:
$(DOCKER) build --tag $(CONTAINER_REPO)/components/producers/tagger:$(DRACON_VERSION) \
--file Dockerfile \
$(DOCKER) --debug build --tag $(CONTAINER_REPO)/components/producers/tagger:$(DRACON_VERSION) \
--build-arg EXECUTABLE_SRC_PATH=components/producers/aggregator/aggregator-parser \
--build-arg EXECUTABLE_TARGET_PATH=components/producers/aggregator/tagger \
$$([ "${SOURCE_CODE_REPO}" != "" ] && echo "--label=org.opencontainers.image.source=${SOURCE_CODE_REPO}" ) \
--build-arg PRODUCER_AGGREGATOR_BASE_IMAGE=$(PRODUCER_AGGREGATOR_BASE_IMAGE) ../../../bin 1>&2
--file ${BASE_IMAGE_PATH} ../../../bin 1>&2

publish:
$(DOCKER) push $(CONTAINER_REPO)/components/producers/tagger:$(DRACON_VERSION) 1>&2
7 changes: 0 additions & 7 deletions components/producers/github-code-scanning/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions components/producers/github-code-scanning/Makefile

This file was deleted.

8 changes: 0 additions & 8 deletions components/producers/ossf-scorecard/Dockerfile

This file was deleted.

16 changes: 0 additions & 16 deletions components/producers/ossf-scorecard/Makefile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG ESLINT_WRAPPER_BASE_IMAGE
FROM ${ESLINT_WRAPPER_BASE_IMAGE}
FROM ${ESLINT_WRAPPER_BASE_IMAGE:-node:lts}

WORKDIR /home/node/workspace
COPY components/producers/typescript-eslint/eslint-wrapper/eslintrc.js /home/node/workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

CONTAINER_REPO=
DRACON_VERSION=
ESLINT_WRAPPER_BASE_IMAGE=$(shell test -e .custom_image && cat .custom_image || echo "node:lts")

DOCKER=docker

Expand Down
21 changes: 21 additions & 0 deletions containers/Dockerfile.base
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:alpine AS builder
northdpole marked this conversation as resolved.
Show resolved Hide resolved

northdpole marked this conversation as resolved.
Show resolved Hide resolved
ARG EXECUTABLE_SRC_PATH
ARG EXECUTABLE_TARGET_PATH
ENV EXECUTABLE_TARGET_PATH=${EXECUTABLE_TARGET_PATH}
COPY ${EXECUTABLE_SRC_PATH} /app/${EXECUTABLE_TARGET_PATH}

RUN apk update && \
apk upgrade && \
apk add --no-cache ca-certificates && \
update-ca-certificates && \
ln -s /app/${EXECUTABLE_TARGET_PATH} /bin/component

FROM scratch

ARG EXECUTABLE_TARGET_PATH
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /app/${EXECUTABLE_TARGET_PATH} /app/${EXECUTABLE_TARGET_PATH}
COPY --from=builder /bin/component /bin/component

ENTRYPOINT ["/bin/component"]
18 changes: 8 additions & 10 deletions scripts/build_component_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ echo "${1}" | grep -Eq ^components/consumers/.*$ && executable="${executable}" |
executable_src_path=$(dirname "${1}")
executable_path=$(dirname "${1}")/"${executable}"

BASE_IMAGE_PATH=$(realpath ${BASE_IMAGE_PATH:-./containers/Dockerfile.base})

if make -C "${executable_src_path}" --no-print-directory --dry-run container >/dev/null 2>&1
then
make -C "${executable_src_path}" --no-print-directory --quiet container CONTAINER_REPO="${CONTAINER_REPO}" DRACON_VERSION="${DRACON_VERSION}"
make -C "${executable_src_path}" --no-print-directory --quiet container BASE_IMAGE_PATH="${BASE_IMAGE_PATH}" CONTAINER_REPO="${CONTAINER_REPO}" DRACON_VERSION="${DRACON_VERSION}"
else
dockerfile_template="
FROM ${BASE_IMAGE:-scratch} \n
COPY ${executable_path} /app/${executable_path} \n
ENTRYPOINT [\"/app/${executable_path}\"] \n
"
dockerfile_path=$(mktemp)
printf "${dockerfile_template}" > "${dockerfile_path}"
docker --debug build -t "${CONTAINER_REPO}/${executable_src_path}:${DRACON_VERSION}" \
docker build \
--build-arg EXECUTABLE_SRC_PATH=${executable_path} \
--build-arg EXECUTABLE_TARGET_PATH=${executable_path} \
-t "${CONTAINER_REPO}/${executable_src_path}:${DRACON_VERSION}" \
$([ "${SOURCE_CODE_REPO}" != "" ] && echo "--label=org.opencontainers.image.source=${SOURCE_CODE_REPO}" ) \
-f "${dockerfile_path}" ./bin
-f "${BASE_IMAGE_PATH}" ./bin
fi

if make -C "${executable_src_path}" --no-print-directory --dry-run extras >/dev/null 2>&1
Expand Down