Skip to content

Commit

Permalink
Merge pull request #52 from wimaha/dev
Browse files Browse the repository at this point in the history
Update Go-Version and add makefile
  • Loading branch information
wimaha authored Sep 16, 2024
2 parents 69309b7 + 37c0ed7 commit c250eb4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 36 deletions.
47 changes: 13 additions & 34 deletions Dockerfile
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"]
34 changes: 34 additions & 0 deletions Makefile
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 \
.
2 changes: 1 addition & 1 deletion go.mod
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
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var exceptedCommands = []string{"charge_port_door_open", "charge_port_door_close
var static embed.FS

func main() {
log.Info("TeslaBleHttpProxy 1.2.4 is loading ...")
log.Info("TeslaBleHttpProxy 1.2.5 is loading ...")

envLogLevel := os.Getenv("logLevel")
if envLogLevel == "debug" {
Expand Down

0 comments on commit c250eb4

Please sign in to comment.