-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from wimaha/dev
Update Go-Version and add makefile
- Loading branch information
Showing
4 changed files
with
49 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,30 @@ | ||
############################ | ||
# STEP 1 build executable binary | ||
############################ | ||
#FROM golang:alpine AS builder | ||
FROM --platform=$BUILDPLATFORM golang:alpine AS builder | ||
FROM --platform=${BUILDPLATFORM} golang:1.23.1 AS builder | ||
|
||
# Install git. | ||
# Git is required for fetching the dependencies. | ||
RUN apk update && apk add --no-cache git tzdata | ||
#RUN apk update && apk add --no-cache git tzdata | ||
WORKDIR $GOPATH/src/wimaha/teslaBleHttpProxy/ | ||
COPY . . | ||
# Fetch dependencies. | ||
# Using go get. | ||
RUN go get -d -v | ||
# Build the binary. | ||
#RUN go build -o /go/bin/teslaBleHttpProxy | ||
#RUN go get -d -v | ||
|
||
ARG TARGETPLATFORM | ||
ARG BUILDPLATFORM | ||
ARG TARGETOS | ||
ARG TARGETARCH | ||
ARG TARGETVARIANT | ||
ARG TARGETPLATFORM | ||
|
||
RUN printf '..%s..' "I'm building for TARGETPLATFORM=${TARGETPLATFORM}" \ | ||
&& printf '..%s..' ", TARGETARCH=${TARGETARCH}" \ | ||
&& printf '..%s..' ", TARGETVARIANT=${TARGETVARIANT} \n" \ | ||
&& printf '..%s..' "With uname -s : " && uname -s \ | ||
&& printf '..%s..' "and uname -m : " && uname -m | ||
|
||
RUN case "${TARGETVARIANT}" in \ | ||
"armhf") export GOARM='6' ;; \ | ||
"armv7") export GOARM='6' ;; \ | ||
"v6") export GOARM='6' ;; \ | ||
"v7") export GOARM='7' ;; \ | ||
esac; | ||
|
||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \ | ||
go build -ldflags="-w -s" -o /go/bin/teslaBleHttpProxy | ||
#RUN GOOS=linux go build -ldflags="-w -s" -o /go/bin/teslaBleHttpProxy | ||
#RUN sudo setcap 'cap_net_admin=eip' "/go/bin/teslaBleHttpProxy" | ||
#WORKDIR /app/ | ||
#ADD . . | ||
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -ldflags="-w -s" -o /go/bin/teslaBleHttpProxy main.go | ||
RUN mkdir -p /go/bin/key | ||
############################ | ||
# STEP 2 build a small image | ||
############################ | ||
|
||
FROM scratch | ||
# Timezone data | ||
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo | ||
ENV TZ=Europe/Berlin | ||
# Copy our static executable. | ||
COPY --from=builder /go/bin/teslaBleHttpProxy /teslaBleHttpProxy | ||
WORKDIR /app/ | ||
COPY --from=builder /go/bin//teslaBleHttpProxy /teslaBleHttpProxy | ||
COPY --from=builder /go/bin/key /key | ||
EXPOSE 8080 | ||
# Run the teslaBleHttpProxy binary. | ||
ENTRYPOINT ["/teslaBleHttpProxy"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
.DEFAULT_GOAL := default | ||
|
||
IMAGE ?= wimaha/tesla-ble-http-proxy | ||
VERSION := 1.2.4 | ||
|
||
export DOCKER_CLI_EXPERIMENTAL=enabled | ||
|
||
.PHONY: build # Build the container image | ||
build: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--output "type=docker,push=false" \ | ||
--tag $(IMAGE) \ | ||
. | ||
|
||
.PHONY: publish # Push the image to the remote registry | ||
publish: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \ | ||
--output "type=image,push=true" \ | ||
--tag $(IMAGE) \ | ||
--tag $(IMAGE):$(VERSION) \ | ||
--tag $(IMAGE):dev \ | ||
. | ||
|
||
.PHONY: publish # Push the image to the remote registry | ||
dev: | ||
@docker buildx create --use --name=crossplat --node=crossplat && \ | ||
docker buildx build \ | ||
--platform linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64,linux/ppc64le \ | ||
--output "type=image,push=true" \ | ||
--tag $(IMAGE):dev \ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module github.com/wimaha/TeslaBleHttpProxy | ||
|
||
go 1.21.3 | ||
go 1.23.1 | ||
|
||
require ( | ||
github.com/charmbracelet/log v0.4.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters