Skip to content

Commit

Permalink
Rename converter to coretemp-converter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyje committed Jan 23, 2023
1 parent 729481f commit c770269
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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,)))
Expand Down Expand Up @@ -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
51 changes: 51 additions & 0 deletions cmd/coretemp-converter/Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>" \
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"
50 changes: 50 additions & 0 deletions cmd/coretemp-converter/Dockerfile.windows
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>" \
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"
File renamed without changes.

0 comments on commit c770269

Please sign in to comment.