Skip to content

add Dockerfile and build.sh to build the static binary #132

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

Closed
wants to merge 7 commits into from
Closed
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: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/cmd/formatter/debug.test
/.cli-config.yml
/wiki
/bin/arduino-cli
18 changes: 18 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
FROM golang:1.11.3-stretch
COPY . /go/src/arduino-cli
WORKDIR /go/src/arduino-cli
RUN go get .
RUN CGO_ENABLED=0 GOOS=linux go install -a -ldflags '-s -w -extldflags "-static"' .

FROM frolvlad/alpine-glibc
RUN apk add ca-certificates python
WORKDIR /root
COPY --from=0 /go/bin/arduino-cli /usr/bin/arduino-cli
ENV USER root
COPY dot-cli-config.yml /usr/bin/.cli-config.yml
RUN arduino-cli core update-index --debug
RUN arduino-cli core install esp8266:esp8266
RUN arduino-cli board listall
RUN arduino-cli sketch new blink --debug
COPY blink.ino /root/Arduino/blink/blink.ino
RUN arduino-cli compile --fqbn esp8266:esp8266:nodemcuv2 Arduino/blink
Empty file added bin/.gitkeepme
Empty file.
10 changes: 10 additions & 0 deletions blink.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
15 changes: 15 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
set -e

banner() {
echo "================================================================"
echo "$1"
echo "================================================================"
}

PROJECT="arduino-cli"

banner "Building docker image..."
docker build -t $PROJECT .
banner "Copying the binary..."
docker run -v ${PWD}/bin:/out:rw $PROJECT
3 changes: 3 additions & 0 deletions dot-cli-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
board_manager:
additional_urls:
- http://arduino.esp8266.com/stable/package_esp8266com_index.json