-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
72 lines (55 loc) · 2.43 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
## build Go executables
FROM golang:1.19-alpine as go-build
## create repo directory
RUN mkdir -p /pico/pico-cs
## install git
RUN apk update && apk upgrade && apk add git
WORKDIR /pico/pico-cs
## clone repo
RUN git clone -b main https://github.com/pico-cs/mqtt-gateway.git
WORKDIR /pico/pico-cs/mqtt-gateway/cmd/gateway
## build for target os architecture
RUN GOOS=linux GOARCH="amd64" go build -v -o /build/gateway/linux/amd64/
RUN GOOS=linux GOARCH="arm64" go build -v -o /build/gateway/linux/arm64/
RUN GOOS=darwin GOARCH="amd64" go build -v -o /build/gateway/darwin/amd64/
RUN GOOS=darwin GOARCH="arm64" go build -v -o /build/gateway/darwin/arm64/
RUN GOOS=windows GOARCH="amd64" go build -v -o /build/gateway/windows/amd64/
RUN GOOS=windows GOARCH="arm64" go build -v -o /build/gateway/windows/arm64/
### Raspberry Pi on Raspberry Pi OS
RUN GOOS=linux GOARCH=arm GOARM=7 go build -v -o /build/gateway/raspos/
## build Raspberry Pi Pico firmware
FROM debian:bullseye as firmware-build
ARG PICO_CS_WIFI_SSID="MyWifiName"
ENV PICO_CS_WIFI_SSID ${PICO_CS_WIFI_SSID}
ARG PICO_CS_WIFI_PASSWORD="MyPassword"
ENV PICO_CS_WIFI_PASSWORD ${PICO_CS_WIFI_PASSWORD}
ARG PICO_CS_TCP_PORT=4242
ENV PICO_CS_TCP_PORT ${PICO_CS_TCP_PORT}
WORKDIR /
## install Raspberry Pi Pico toolchain
RUN su -
RUN apt update
RUN apt install -y git
RUN apt install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
RUN apt install -y python3
RUN exit
## install SDK
RUN mkdir -p build/firmware
RUN mkdir -p pico
RUN cd pico; git clone -b master https://github.com/raspberrypi/pico-sdk.git
RUN cd pico/pico-sdk; git submodule update --init
## build firmware
RUN mkdir pico/pico-cs
RUN cd pico/pico-cs; git clone -b main https://github.com/pico-cs/firmware.git
RUN mkdir /pico/pico-cs/firmware/src/pico_build
RUN export PICO_SDK_PATH=/pico/pico-sdk; cd /pico/pico-cs/firmware/src/pico_build; cmake .. -DPICO_BOARD=pico; make
RUN mkdir /pico/pico-cs/firmware/src/pico_w_build
RUN export PICO_SDK_PATH=/pico/pico-sdk; cd /pico/pico-cs/firmware/src/pico_w_build; cmake .. -DPICO_BOARD=pico_w; make
## copy to build directory
RUN cp /pico/pico-cs/firmware/src/pico_build/cs.uf2 /build/firmware/
RUN cp /pico/pico-cs/firmware/src/pico_w_build/cs_w.uf2 /build/firmware/
## copy build artefacts to local host
## DOCKER_BUILDKIT=1 docker build --output type=local,dest=. .
FROM scratch as artefact
COPY --from=go-build /build ./build/
COPY --from=firmware-build /build ./build/