-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
110 lines (86 loc) · 4 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
ARG GRENDEL_VERSION=0.8.6
# ---------------------------------------------------
FROM --platform=linux/arm64/v8 docker.io/library/alpine:edge as ipxe-builder-arm64
# ---------------------------------------------------
RUN apk add --no-cache \
gcc \
make \
wget \
git \
perl \
xz-dev \
musl-dev
WORKDIR /work
ARG GRENDEL_VERSION
RUN git clone -b ${GRENDEL_VERSION} --recursive https://github.com/SquareFactory/grendel.git \
&& cd grendel/firmware/ipxe/src \
&& git checkout master \
&& git pull
RUN cd grendel/firmware/ipxe/src \
&& sed -i '/^\/\/#define VLAN_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define DIGEST_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define NSLOOKUP_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define PING_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define NTP_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define\tCONSOLE_SYSLOG/s/^\/\///' config/console.h \
&& sed -i '/^\/\/#define\tCONSOLE_SYSLOGS/s/^\/\///' config/console.h \
&& make -j$(nproc) bin-arm64-efi/ipxe.efi EMBED=../../boot.ipxe
# ---------------------------------------------------
FROM --platform=linux/amd64 docker.io/library/alpine:edge as ipxe-builder-amd64
# ---------------------------------------------------
RUN apk add --no-cache \
gcc \
make \
wget \
git \
perl \
xz-dev \
musl-dev
WORKDIR /work
ARG GRENDEL_VERSION
RUN git clone -b ${GRENDEL_VERSION} --recursive https://github.com/SquareFactory/grendel.git \
&& cd grendel/firmware/ipxe/src \
&& git checkout master \
&& git pull
RUN cd grendel/firmware/ipxe/src \
&& sed -i '/^\/\/#define VLAN_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define DIGEST_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define NSLOOKUP_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define PING_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define NTP_CMD/s/^\/\///' config/general.h \
&& sed -i '/^\/\/#define\tCONSOLE_SYSLOG/s/^\/\///' config/console.h \
&& sed -i '/^\/\/#define\tCONSOLE_SYSLOGS/s/^\/\///' config/console.h \
&& make -j$(nproc) bin/ipxe.pxe \
bin/undionly.kpxe \
bin-x86_64-efi/ipxe.efi \
bin-x86_64-efi/snponly.efi \
bin-i386-efi/ipxe.efi \
EMBED=../../boot.ipxe
# ---------------------------------------------------
FROM docker.io/library/alpine:edge as grendel-builder
# ---------------------------------------------------
RUN apk add --no-cache \
git
ARG TARGETOS TARGETARCH VERSION=dev
COPY --from=docker.io/library/golang:1.20.2-alpine /usr/local/go/ /usr/local/go/
ENV PATH="${PATH}:/usr/local/go/bin"
WORKDIR /work
ARG GRENDEL_VERSION
RUN git clone -b ${GRENDEL_VERSION} https://github.com/SquareFactory/grendel.git
COPY --from=ipxe-builder-arm64 /work/grendel/firmware/ipxe/src/bin-arm64-efi/ipxe.efi /work/grendel/firmware/bin/ipxe-arm64.efi
COPY --from=ipxe-builder-amd64 /work/grendel/firmware/ipxe/src/bin/ipxe.pxe /work/grendel/firmware/bin/ipxe.pxe
COPY --from=ipxe-builder-amd64 /work/grendel/firmware/ipxe/src/bin/undionly.kpxe /work/grendel/firmware/bin/undionly.kpxe
COPY --from=ipxe-builder-amd64 /work/grendel/firmware/ipxe/src/bin-x86_64-efi/ipxe.efi /work/grendel/firmware/bin/ipxe-x86_64.efi
COPY --from=ipxe-builder-amd64 /work/grendel/firmware/ipxe/src/bin-x86_64-efi/snponly.efi /work/grendel/firmware/bin/snponly-x86_64.efi
COPY --from=ipxe-builder-amd64 /work/grendel/firmware/ipxe/src/bin-i386-efi/ipxe.efi /work/grendel/firmware/bin/ipxe-i386.efi
RUN cd grendel \
&& CGO_ENABLED=0 GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o grendel .
# ---------------------------------------------------
FROM docker.io/library/alpine:edge
# ---------------------------------------------------
RUN apk add --no-cache xz-libs ipmitool
LABEL MAINTAINER Square Factory
WORKDIR /app
COPY --from=grendel-builder /work/grendel/grendel /app/grendel
ENTRYPOINT [ "/app/grendel" ]
CMD ["--debug", "--verbose", "serve", "-c", "/var/lib/grendel/grendel.toml", "--hosts", "/var/lib/grendel/host.json", "--images", "/var/lib/grendel/image.json", "--listen", "0.0.0.0"]