Skip to content

Commit

Permalink
compile.bk2
Browse files Browse the repository at this point in the history
  • Loading branch information
sam#gemmi-win10 authored and huapox committed Nov 8, 2023
1 parent 9e9b442 commit 66b30da
Showing 1 changed file with 223 additions and 0 deletions.
223 changes: 223 additions & 0 deletions compile/build-alpine/Dockerfile.bk2
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
# ARG BASEIMAGE=alpine:3.15
ARG BASEIMAGE=compile
FROM registry.cn-shenzhen.aliyuncs.com/infrastlabs/x11-base:alpine-compile as compile
FROM infrastlabs/x11-base:builder AS base
ARG TARGETPLATFORM
ENV CACHE=/usr/local/static/.cache
RUN apk update; apk add gawk git;
COPY --from=compile /rootfs${CACHE} ${CACHE}
COPY ./src /src
RUN chmod +x /src/**/*.sh; \
ls -lh /src/**/*.sh

# --platform=$BUILDPLATFORM
FROM base as tiger
ARG COMPILE_TIGER="yes"
ENV TARGETPATH=/usr/local/static/tigervnc
RUN mkdir -p $TARGETPATH; \
sh /src/x-tigervnc/build.sh cache; \
\
# https://blog.csdn.net/sodaloveer/article/details/127727729 #wait并行
test "yes" != "$COMPILE_TIGER" && exit 0 || echo doMake; \
sh /src/x-tigervnc/build.sh b_deps; \
sh /src/x-tigervnc/build.sh b_tiger; \
\
find ${TARGETPATH} -type f |sort
# xx-verify --static ${TARGETPATH}/bin/Xvnc; \
# xx-verify --static ${TARGETPATH}/bin/vncpasswd; \
# upx ${TARGETPATH}/bin/Xvnc; \
# upx ${TARGETPATH}/bin/vncpasswd
# validate
# RUN du -sh /rootfs; \
# /rootfs/usr/bin/Xvnc -version; \
# find /rootfs -type f |sort

# Build xdpyprobe.
# Used to determine if the X server (Xvnc) is ready.
# FROM infrastlabs/x11-base:builder AS xdpyprobe
# ARG TARGETPLATFORM
COPY src/xdpyprobe /tmp/xdpyprobe
# RUN apk --no-cache add make clang
# RUN xx-apk --no-cache add gcc musl-dev libx11-dev libx11-static libxcb-static
#
RUN \
CC=xx-clang make -C /tmp/xdpyprobe; \
xx-verify --static /tmp/xdpyprobe/xdpyprobe; \
upx /tmp/xdpyprobe/xdpyprobe



FROM base as xrdp
ARG COMPILE_XRDP="yes"
ENV CONSOLE_LOG=no \
TARGETPATH=/usr/local/static/xrdp
## build.sh: split multi steps, to speed up
RUN mkdir -p $TARGETPATH; \
sh /src/x-xrdp/build.sh cache; \
\
test "yes" != "$COMPILE_XRDP" && exit 0 || echo doMake; \
sh /src/x-xrdp/build.sh b_deps; \
sh /src/x-xrdp/build.sh xrdp; \
\
find ${TARGETPATH} -type f |sort; \
xx-verify --static ${TARGETPATH}/sbin/xrdp; \
xx-verify --static ${TARGETPATH}/sbin/xrdp-chansrv; \
upx ${TARGETPATH}/sbin/xrdp; \
upx ${TARGETPATH}/sbin/xrdp-chansrv

FROM base as dropbear
ARG COMPILE_SSH="yes"
ENV CONSOLE_LOG=no \
TARGETPATH=/usr/local/static/dropbear
RUN mkdir -p $TARGETPATH; \
# sh /src/x-dropbear/build.sh cache; \
\
test "yes" != "$COMPILE_SSH" && exit 0 || echo doMake; \
sh /src/x-dropbear/build.sh dropbear; \
\
find ${TARGETPATH} -type f |sort;


FROM base as fluxbox
ARG COMPILE_FLUX="yes"
ENV CONSOLE_LOG=no \
TARGETPATH=/usr/local/static/fluxbox
RUN mkdir -p $TARGETPATH; \
# sh /src/fluxbox/build.sh cache; \
\
test "yes" != "$COMPILE_FLUX" && exit 0 || echo doMake; \
sh /src/x-xrdp/build.sh libxrandr; \
sh /src/fluxbox/build.sh fluxbox; \
\
find ${TARGETPATH} -type f |sort;

FROM base as suckless
ARG COMPILE_SUCKLESS="yes"
ENV CONSOLE_LOG=no \
TARGETPATH=/usr/local/static/suckless
RUN mkdir -p $TARGETPATH; \
# sh /src/suckless/build.sh cache; \
\
test "yes" != "$COMPILE_SUCKLESS" && exit 0 || echo doMake; \
sh /src/suckless/build.sh st; \
sh /src/suckless/build.sh dwm; \
sh /src/suckless/build.sh dmenu; \
\
find ${TARGETPATH} -type f |sort;


# Build Openbox.
# FROM infrastlabs/x11-base:builder AS openbox
FROM base as openbox
ARG COMPILE_OPENBOX="yes"
ENV CONSOLE_LOG=no \
TARGETPATH=/usr/local/static/openbox
# ARG TARGETPLATFORM
# COPY --from=fontconfig /tmp/fontconfig-install /tmp/fontconfig-install
# COPY src/openbox /tmp/build
# RUN /tmp/build/build.sh
RUN mkdir -p $TARGETPATH; \
sh /src/openbox/build.sh cache; \
\
test "yes" != "$COMPILE_OPENBOX" && exit 0 || echo doMake; \
# configure: error: C compiler cannot create executables
# sh /src/openbox/build.sh b_deps; \
# sh /src/openbox/build.sh openbox; \
\
# old:
sh /src/_ex/fontconfig/build.sh; \
sh /src/openbox/build.sh.bk1.sh; \
\
find ${TARGETPATH} -type f |sort;
# RUN xx-verify --static \
# /tmp/openbox-install/usr/bin/openbox \
# /tmp/openbox-install/usr/bin/obxprop
# RUN upx /tmp/openbox-install/usr/bin/openbox
# RUN upx /tmp/openbox-install/usr/bin/obxprop
RUN cp /tmp/openbox-install ${TARGETPATH}/; \
cp /tmp/fontconfig-install ${TARGETPATH}/; \
du -sh ${TARGETPATH}/*

# Build yad.
# FROM infrastlabs/x11-base:builder AS yad
# ARG TARGETPLATFORM
# COPY --from=fontconfig /tmp/fontconfig-install /tmp/fontconfig-install
# COPY src/yad/build.sh /tmp/build-yad.sh
# RUN /tmp/build-yad.sh
# RUN xx-verify --static /tmp/yad-install/usr/bin/yad
# RUN upx /tmp/yad-install/usr/bin/yad

# Build Fontconfig.
# FROM infrastlabs/x11-base:builder AS fontconfig
# ARG TARGETPLATFORM
# COPY src/fontconfig/build.sh /tmp/build-fontconfig.sh
# RUN /tmp/build-fontconfig.sh


# FROM compile
# FROM ${BASEIMAGE} #导致img嵌套,层次达max;
FROM registry.cn-shenzhen.aliyuncs.com/infrastlabs/x11-base:alpine-compile as ff
FROM alpine:3.15
COPY --from=ff /rootfs /rootfs
RUN export domain="mirrors.ustc.edu.cn"; \
echo "http://$domain/alpine/v3.15/main" > /etc/apk/repositories; \
echo "http://$domain/alpine/v3.15/community" >> /etc/apk/repositories;
# arm64: 无upx包..>> TODO static-upx
# \
# apk update; apk add upx; upx -V
ENV STATIC=/usr/local/static
WORKDIR ${STATIC}

# Add files.
# COPY --link --from=tigervnc /tmp/tigervnc-install/usr/bin/Xvnc /rootfs/usr/bin/
# COPY --link --from=tigervnc /tmp/tigervnc-install/usr/bin/vncpasswd /rootfs/usr/bin/
# COPY --link --from=tigervnc /tmp/xkb-install/usr/share/X11/xkb /rootfs/usr/share/X11/xkb
# COPY --link --from=tigervnc /tmp/xkbcomp-install/usr/bin/xkbcomp /rootfs/usr/bin/
# COPY --link --from=xdpyprobe /tmp/xdpyprobe/xdpyprobe /rootfs/usr/bin/
#
# COPY --link --from=fontconfig /tmp/fontconfig-install/opt /opt
# COPY --link --from=openbox /tmp/openbox-install/usr/bin/openbox /rootfs/usr/bin/
# COPY --link --from=openbox /tmp/openbox-install/usr/bin/obxprop /rootfs/usr/bin/
# COPY --link --from=yad /tmp/yad-install/usr/bin/yad /rootfs/usr/bin/
#
# COPY --link --from=nginx /tmp/nginx-install /rootfs/usr/
# COPY --link --from=dhparam /tmp/dhparam.pem /defaults/
# COPY --link --from=noVNC /opt/noVNC /opt/noVNC


# view01
# find |while read one; do md5sum..; echo "$md5|$one" > list-$rq-f.txt; done
RUN find /rootfs${STATIC} -type f |sort |wc

# CARE!! dirty clear;
# RUN rm -rf /rootfs${STATIC}/tigervnc
# stages: 未用到的stage,会跳过构建
COPY --from=tiger ${STATIC} /rootfs${STATIC}
COPY --from=xrdp ${STATIC} /rootfs${STATIC}
COPY --from=dropbear ${STATIC} /rootfs${STATIC}
COPY --from=fluxbox ${STATIC} /rootfs${STATIC}
COPY --from=openbox ${STATIC} /rootfs${STATIC}
COPY --from=suckless ${STATIC} /rootfs${STATIC}

# clear lib,share/man; create links: (ubt/deb: bin> /usr/bin)
RUN rm -rf /rootfs/usr/bin /rootfs/usr/sbin; mkdir -p /rootfs/usr/bin /rootfs/usr/sbin; \
find /rootfs/usr/local/static -type d |egrep "/share/man$|xrdp/lib$" | \
while read one; do du -sh $one; rm -rf $one; done; \
\
find /rootfs/usr/local/static -type f |grep "/sbin/" |sort | \
while read one; do ls -lh $one; one2=$(echo $one|sed "s^/rootfs^^g"); ln -s $one2 /rootfs/usr/sbin/; done; \
\
find /rootfs/usr/local/static -type f |grep "/bin/" |sort | \
while read one; do ls -lh $one; one2=$(echo $one|sed "s^/rootfs^^g"); ln -s $one2 /rootfs/usr/bin/; done;
# keeplist, outDir;
# ..
# upx
# RUN \
# upx /rootfs${STATIC}/suckless/bin/st; \
# upx /rootfs${STATIC}/suckless/bin/dwm; \
# upx /rootfs${STATIC}/suckless/bin/dmenu
# view02
RUN find /rootfs${STATIC} -type f |sort |wc
RUN find /rootfs${STATIC} -type f |sort
# RUN rm -rf ${STATIC}; ln -s /rootfs${STATIC} ${STATIC}

0 comments on commit 66b30da

Please sign in to comment.