-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDockerfile.openwrt
40 lines (28 loc) · 1.01 KB
/
Dockerfile.openwrt
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
FROM golang:1.22 as builder
ARG version
ENV VERSION_VAR=go.qbee.io/agent/app.Version
ENV CGO_ENABLED=0
WORKDIR /src
COPY . /src
# build the agent
RUN --mount=type=cache,target=/go \
--mount=type=cache,target=/root/.cache/go-build \
go build \
-ldflags "-s -w -X ${VERSION_VAR}=$version" \
-o /usr/bin/qbee-agent \
main.go
# Get the openwrt rootfs
ADD https://downloads.openwrt.org/releases/23.05.0/targets/x86/64/openwrt-23.05.0-x86-64-rootfs.tar.gz /src/rootfs.tar.gz
RUN mkdir /rootfs
RUN tar -xz -C /rootfs -f /src/rootfs.tar.gz
FROM scratch
COPY --from=builder /rootfs /
RUN mkdir -p /var/lock
RUN sed -i '/^exit 0/i cat \/tmp\/resolv.conf > \/etc\/resolv.conf' /etc/rc.local
COPY test/resources/opkg /opkg-repo
RUN echo "src/gz qbee file:///opkg-repo/repo" >> /etc/opkg/customfeeds.conf
RUN sed -i '/option check_signature/d' /etc/opkg.conf
RUN mkdir /etc/qbee && echo '{}' > /etc/qbee/qbee-agent.json
COPY --from=builder /usr/bin/qbee-agent /usr/bin/qbee-agent
WORKDIR /app
CMD [ "/bin/sh" ]