From c7702695d015c37f0290ebc97ad2e82173dea8c6 Mon Sep 17 00:00:00 2001 From: Jeremy Edwards <1312331+jeremyje@users.noreply.github.com> Date: Mon, 23 Jan 2023 06:30:24 +0000 Subject: [PATCH] Rename converter to coretemp-converter. --- Makefile | 15 ++++-- cmd/coretemp-converter/Dockerfile | 51 +++++++++++++++++++ cmd/coretemp-converter/Dockerfile.windows | 50 ++++++++++++++++++ .../coretemp-converter.go} | 0 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 cmd/coretemp-converter/Dockerfile create mode 100644 cmd/coretemp-converter/Dockerfile.windows rename cmd/{converter/converter.go => coretemp-converter/coretemp-converter.go} (100%) diff --git a/Makefile b/Makefile index 7d6af8b..4baf193 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ LINUX_NICHE_PLATFORMS = WINDOWS_PLATFORMS = windows_386 windows_amd64 MAIN_PLATFORMS = windows_amd64 linux_amd64 linux_arm64 ALL_PLATFORMS = $(LINUX_PLATFORMS) $(LINUX_NICHE_PLATFORMS) $(WINDOWS_PLATFORMS) $(foreach niche,$(NICHE_PLATFORMS),$(niche)_amd64 $(niche)_arm64) -ALL_APPS = coretemp-exporter converter +ALL_APPS = coretemp-exporter coretemp-converter MAIN_BINARIES = $(foreach app,$(ALL_APPS),$(foreach platform,$(MAIN_PLATFORMS),build/bin/$(platform)/$(app)$(if $(findstring windows_,$(platform)),.exe,))) ALL_BINARIES = $(foreach app,$(ALL_APPS),$(foreach platform,$(ALL_PLATFORMS),build/bin/$(platform)/$(app)$(if $(findstring windows_,$(platform)),.exe,))) @@ -110,22 +110,27 @@ images: linux-images windows-images ALL_LINUX_IMAGES = $(foreach app,$(ALL_APPS),$(foreach platform,$(LINUX_PLATFORMS),linux-image-$(app)-$(platform))) linux-images: $(ALL_LINUX_IMAGES) +ALL_WINDOWS_IMAGES = $(foreach app,$(ALL_APPS),$(foreach winver,$(WINDOWS_VERSIONS),windows-image-$(app)-$(winver))) +windows-images: $(ALL_WINDOWS_IMAGES) linux-image-coretemp-exporter-%: build/bin/%/coretemp-exporter ensure-builder $(DOCKER) buildx build $(DOCKER_BUILDER_FLAG) --platform $(subst _,/,$*) --build-arg BINARY_PATH=$< -f cmd/coretemp-exporter/Dockerfile -t $(CORETEMP_EXPORTER_IMAGE):$(TAG)-$* . $(DOCKER_PUSH) -ALL_WINDOWS_IMAGES = $(foreach app,$(ALL_APPS),$(foreach winver,$(WINDOWS_VERSIONS),windows-image-$(app)-$(winver))) -windows-images: $(ALL_WINDOWS_IMAGES) - windows-image-coretemp-exporter-%: build/bin/windows_amd64/coretemp-exporter.exe ensure-builder $(DOCKER) buildx build $(DOCKER_BUILDER_FLAG) --platform windows/amd64 -f cmd/coretemp-exporter/Dockerfile.windows --build-arg WINDOWS_VERSION=$* -t $(CORETEMP_EXPORTER_IMAGE):$(TAG)-windows_amd64-$* . $(DOCKER_PUSH) +linux-image-coretemp-converter-%: build/bin/%/coretemp-converter ensure-builder + $(DOCKER) buildx build $(DOCKER_BUILDER_FLAG) --platform $(subst _,/,$*) --build-arg BINARY_PATH=$< -f cmd/coretemp-converter/Dockerfile -t $(CORETEMP_EXPORTER_IMAGE):$(TAG)-$* . $(DOCKER_PUSH) + +windows-image-coretemp-converter-%: build/bin/windows_amd64/coretemp-converter.exe ensure-builder + $(DOCKER) buildx build $(DOCKER_BUILDER_FLAG) --platform windows/amd64 -f cmd/coretemp-converter/Dockerfile.windows --build-arg WINDOWS_VERSION=$* -t $(CORETEMP_EXPORTER_IMAGE):$(TAG)-windows_amd64-$* . $(DOCKER_PUSH) + clean: rm -f coverage.txt -chmod -R +w build/ rm -rf build/ convert: - $(GO) run cmd/converter/converter.go -input=cputemps.ndjson -output=cputemps.csv -mode=csv + $(GO) run cmd/coretemp-converter/coretemp-converter.go -input=cputemps.ndjson -output=cputemps.csv -mode=csv .PHONY: all run lint test clean diff --git a/cmd/coretemp-converter/Dockerfile b/cmd/coretemp-converter/Dockerfile new file mode 100644 index 0000000..7e371c1 --- /dev/null +++ b/cmd/coretemp-converter/Dockerfile @@ -0,0 +1,51 @@ +# Copyright 2023 Jeremy Edwards +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM --platform=$BUILDPLATFORM gcr.io/distroless/static:nonroot + +ARG BINARY_PATH + +WORKDIR /app/ + +COPY --chown=nonroot $BINARY_PATH /app/coretemp-converter +COPY --chown=nonroot LICENSE /app/LICENSE + +EXPOSE 8181 +ENTRYPOINT ["/app/coretemp-converter"] + +# Standardized Docker Image Labels +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +LABEL \ + org.opencontainers.image.created="${BUILD_TIME}" \ + org.opencontainers.image.authors="Jeremyje " \ + org.opencontainers.image.url="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.documentation="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.source="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.version="${BUILD_VERSION}" \ + org.opencontainers.image.revision="1" \ + org.opencontainers.image.vendor="Jeremy Edwards" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.ref.name="" \ + org.opencontainers.image.title="${BINARY_NAME}" \ + org.opencontainers.image.description="Core Temp Converter for Prometheus" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.url="https://github.com/jeremyje/coretemp-exporter" \ + org.label-schema.vcs-url="https://github.com/jeremyje/coretemp-exporter" \ + org.label-schema.version=$BUILD_VERSION \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vendor="Jeremy Edwards" \ + org.label-schema.name="${BINARY_NAME}" \ + org.label-schema.description="Core Temp Converter for Prometheus" \ + org.label-schema.usage="https://github.com/jeremyje/coretemp-exporter" diff --git a/cmd/coretemp-converter/Dockerfile.windows b/cmd/coretemp-converter/Dockerfile.windows new file mode 100644 index 0000000..8593c6f --- /dev/null +++ b/cmd/coretemp-converter/Dockerfile.windows @@ -0,0 +1,50 @@ +# Copyright 2023 Jeremy Edwards +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +ARG WINDOWS_VERSION=1809 + +FROM mcr.microsoft.com/windows/nanoserver:${WINDOWS_VERSION} + +COPY build/bin/windows_amd64/coretemp-converter.exe /app/coretemp-converter.exe +COPY LICENSE /app/LICENSE + +USER ContainerUser +EXPOSE 8181 +ENTRYPOINT ["/app/coretemp-converter.exe"] + +# Standardized Docker Image Labels +# https://github.com/opencontainers/image-spec/blob/master/annotations.md +LABEL \ + org.opencontainers.image.created="${BUILD_TIME}" \ + org.opencontainers.image.authors="Jeremyje " \ + org.opencontainers.image.url="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.documentation="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.source="https://github.com/jeremyje/coretemp-exporter" \ + org.opencontainers.image.version="${BUILD_VERSION}" \ + org.opencontainers.image.revision="1" \ + org.opencontainers.image.vendor="Jeremy Edwards" \ + org.opencontainers.image.licenses="Apache-2.0" \ + org.opencontainers.image.ref.name="" \ + org.opencontainers.image.title="${BINARY_NAME}" \ + org.opencontainers.image.description="Core Temp Converter for Prometheus" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.build-date=$BUILD_DATE \ + org.label-schema.url="https://github.com/jeremyje/coretemp-exporter" \ + org.label-schema.vcs-url="https://github.com/jeremyje/coretemp-exporter" \ + org.label-schema.version=$BUILD_VERSION \ + org.label-schema.vcs-ref=$VCS_REF \ + org.label-schema.vendor="Jeremy Edwards" \ + org.label-schema.name="${BINARY_NAME}" \ + org.label-schema.description="Core Temp Converter for Prometheus" \ + org.label-schema.usage="https://github.com/jeremyje/coretemp-exporter" diff --git a/cmd/converter/converter.go b/cmd/coretemp-converter/coretemp-converter.go similarity index 100% rename from cmd/converter/converter.go rename to cmd/coretemp-converter/coretemp-converter.go