Skip to content

Commit 678ee7c

Browse files
authored
Merge pull request #82 from netbootxyz/optimize_size
Optimize size with multi stage build
2 parents 507deff + 426084c commit 678ee7c

File tree

1 file changed

+47
-39
lines changed

1 file changed

+47
-39
lines changed

Dockerfile

+47-39
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,58 @@
1+
FROM alpine:3.21.3 AS build
2+
3+
# set version label
4+
ARG WEBAPP_VERSION
5+
6+
RUN apk add --no-cache \
7+
bash \
8+
busybox \
9+
curl \
10+
git \
11+
jq \
12+
npm && \
13+
mkdir /app && \
14+
if [ -z ${WEBAPP_VERSION+x} ]; then \
15+
WEBAPP_VERSION=$(curl -sX GET "https://api.github.com/repos/netbootxyz/webapp/releases/latest" \
16+
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
17+
fi && \
18+
curl -o /tmp/webapp.tar.gz -L \
19+
"https://github.com/netbootxyz/webapp/archive/${WEBAPP_VERSION}.tar.gz" && \
20+
tar xf /tmp/webapp.tar.gz -C /app/ --strip-components=1 && \
21+
npm install --prefix /app && \
22+
rm -rf /tmp/*
23+
124
FROM alpine:3.21.3
225

326
# set version label
427
ARG BUILD_DATE
528
ARG VERSION
6-
ARG WEBAPP_VERSION
729

830
LABEL build_version="netboot.xyz version: ${VERSION} Build-date: ${BUILD_DATE}"
931
LABEL maintainer="antonym"
10-
LABEL org.opencontainers.image.description netboot.xyz official docker container - Your favorite operating systems in one place. A network-based bootable operating system installer based on iPXE.
11-
12-
RUN \
13-
apk add --no-cache \
14-
bash \
15-
busybox \
16-
curl \
17-
envsubst \
18-
git \
19-
jq \
20-
nghttp2-dev \
21-
nginx \
22-
nodejs \
23-
shadow \
24-
sudo \
25-
supervisor \
26-
syslog-ng \
27-
tar \
28-
dnsmasq && \
29-
apk add --no-cache --virtual=build-dependencies \
30-
npm && \
31-
groupmod -g 1000 users && \
32-
useradd -u 911 -U -d /config -s /bin/false nbxyz && \
33-
usermod -G users nbxyz && \
34-
mkdir /app \
35-
/config \
36-
/defaults && \
37-
if [ -z ${WEBAPP_VERSION+x} ]; then \
38-
WEBAPP_VERSION=$(curl -sX GET "https://api.github.com/repos/netbootxyz/webapp/releases/latest" \
39-
| awk '/tag_name/{print $4;exit}' FS='[""]'); \
40-
fi && \
41-
curl -o /tmp/webapp.tar.gz -L \
42-
"https://github.com/netbootxyz/webapp/archive/${WEBAPP_VERSION}.tar.gz" && \
43-
tar xf /tmp/webapp.tar.gz -C \
44-
/app/ --strip-components=1 && \
45-
npm install --prefix /app && \
46-
apk del --purge build-dependencies && \
47-
rm -rf /tmp/*
32+
LABEL org.opencontainers.image.description="netboot.xyz official docker container - Your favorite operating systems in one place. A network-based bootable operating system installer based on iPXE."
33+
34+
RUN apk add --no-cache \
35+
bash \
36+
busybox \
37+
curl \
38+
dnsmasq \
39+
envsubst \
40+
git \
41+
jq \
42+
nghttp2-dev \
43+
nginx \
44+
nodejs \
45+
shadow \
46+
sudo \
47+
supervisor \
48+
syslog-ng \
49+
tar && \
50+
groupmod -g 1000 users && \
51+
useradd -u 911 -U -d /config -s /bin/false nbxyz && \
52+
usermod -G users nbxyz && \
53+
mkdir /app /config /defaults
54+
55+
COPY --from=build /app /app
4856

4957
ENV TFTPD_OPTS=''
5058
ENV NGINX_PORT='80'

0 commit comments

Comments
 (0)