generated from bfren/docker-alpine
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockerfile.esh
146 lines (115 loc) · 5.65 KB
/
Dockerfile.esh
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#======================================================================================================================
# STAGE 0: get build information and download Nushell
#======================================================================================================================
FROM --platform=${BUILDPLATFORM} golang:alpine AS build
ARG TARGETPLATFORM
RUN \
# save platform and version information to log
echo "Platform: ${TARGETPLATFORM}" >> /log && \
echo "Debian: <%= ${DEBIAN_MINOR} %>" >> /log && \
echo "Busybox: <%= ${BUSYBOX_VERSION} %>" >> /log && \
echo "Nushell: <%= ${NUSHELL_VERSION} %>" >> /log
WORKDIR /tmp
RUN \
# build a URL to download and extract Nushell binaries from a release
echo "Installing Nushell." && \
case "${TARGETPLATFORM}" in \
linux/amd64) ARCH="x86_64" ; COMP="gnu" ;; \
linux/arm/v7) ARCH="armv7" ; COMP="gnueabihf" ;; \
linux/arm64) ARCH="aarch64" ; COMP="gnu" ;; \
*) echo "Unsupported target platform: ${TARGETPLATFORM}." && exit 1 ;; \
esac && \
NAME=nu-<%= ${NUSHELL_VERSION} %>-${ARCH}-unknown-linux-${COMP} && \
URL=https://github.com/nushell/nushell/releases/download/<%= ${NUSHELL_VERSION} %>/${NAME}.tar.gz && \
wget ${URL} && \
tar -oxzf ${NAME}.tar.gz && \
mkdir /nu && \
mv ${NAME}/nu /nu && \
mkdir /nu-config && \
mv ${NAME}/LICENSE ${NAME}/README.txt /nu-config && \
mkdir /nu-plugins && \
mv ${NAME}/nu_plugin* /nu-plugins
ADD https://raw.githubusercontent.com/bfren/nushell/main/<%= ${NUSHELL_VERSION} %>/config.nu /nu-config/config.nu
ADD https://raw.githubusercontent.com/bfren/nushell/main/<%= ${NUSHELL_VERSION} %>/env.nu /nu-config/env.nu
#======================================================================================================================
# STAGE 1: move Nushell files into their correct locations
#======================================================================================================================
FROM scratch as nushell
COPY --from=build /nu/ /usr/bin/
COPY --from=build /nu-config/ /root/.config/nushell/
COPY --from=build /nu-plugins/ /root/.config/nushell/plugins/
#======================================================================================================================
# STAGE 2: load busybox
#======================================================================================================================
FROM ghcr.io/bfren/busybox:<%= ${BUSYBOX_IMAGE} %> AS busybox-executable
#======================================================================================================================
# STAGE 3: install busybox
#======================================================================================================================
FROM debian:<%= ${DEBIAN_MINOR} %>-slim AS busybox
COPY --from=busybox-executable / /bin
RUN \
# delete all binaries that will be replaced by busybox - those in ${IGNORE} will be left alone
echo "Installing busybox." && \
X=$(busybox --list-full) ; \
IGNORE="[ [[ addgroup adduser cmp dpkg dpkg-deb df find grep logger mkdir setarch" ; \
for A in ${X} ; do \
if busybox printf "%s\0" "${IGNORE}" | busybox grep -q -F `busybox basename ${A}` ; then continue ; \
else busybox rm -f /${A} ; \
fi ; \
done ; \
# install busybox
busybox --install
#======================================================================================================================
# STAGE 4: get overlay from Alpine image
#======================================================================================================================
FROM alpine AS alpine
WORKDIR /tmp
RUN \
# get the overlay from the Alpine base image
echo "Cloning Alpine overlay." && \
apk add git && git clone --branch <%= ${ALPINE_BRANCH} %> https://github.com/bfren/docker-alpine.git && \
mv docker-alpine/overlay /
#======================================================================================================================
# STAGE 5: install bfren platform
#======================================================================================================================
FROM debian:<%= ${DEBIAN_MINOR} %>-slim as install
COPY --from=build /log /etc/bf/BUILD
COPY --from=alpine /overlay /
COPY --from=busybox / /
COPY --from=nushell / /
ARG BF_IMAGE
ARG BF_VERSION
COPY ./overlay /
ENV \
# path to bf configuration - installation script requires this
BF_ETC=<%= ${BF_ETC} %> \
# set container to this timezone
BF_TZ=Europe/London \
# whether or not to upgrade packages during installation
# 0: no
# 1: yes
BF_UPGRADE_PACKAGES=0 \
# Nushell version string to check against installed verion after installation
NUSHELL_VERSION=<%= ${NUSHELL_VERSION} %>
RUN \
# setup Nushell using preinstallation script
chmod +x /preinstall && /preinstall && \
# run standard bf installation executable
<%= ${BF_BIN} %>/bf-install
#======================================================================================================================
# STAGE 6: create final image
#======================================================================================================================
FROM scratch as final
COPY --from=install / /
LABEL org.opencontainers.image.description="Debian Linux with default Busybox and Nushell installed."
LABEL org.opencontainers.image.source="https://github.com/bfren/docker-debian"
ENV \
# debug log output
# 0: disable
# 1: enable
BF_DEBUG=0 \
# path to bfren configuration directory
BF_ETC=<%= ${BF_ETC} %> \
# add bfren executables to PATH
PATH=<%= ${BF_BIN} %>:${PATH}
ENTRYPOINT [ "/init" ]