generated from bfren/docker-alpine
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.esh
114 lines (89 loc) · 4.27 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
#======================================================================================================================
# STAGE 0: store build information
#======================================================================================================================
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: <%= ${NU_VERSION} %>" >> /log
#======================================================================================================================
# STAGE 1: load busybox
#======================================================================================================================
FROM ghcr.io/bfren/busybox:<%= ${BUSYBOX_IMAGE} %> AS busybox
#======================================================================================================================
# STAGE 2: load Nushell
#======================================================================================================================
FROM ghcr.io/bfren/nushell:<%= ${NU_IMAGE} %> AS nushell
#======================================================================================================================
# STAGE 3: get overlay from Alpine image
#======================================================================================================================
FROM ghcr.io/bfren/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 4: install bfren platform
#======================================================================================================================
FROM debian:<%= ${DEBIAN_MINOR} %>-slim AS install
COPY --from=build /log /etc/bf/BUILD
COPY --from=alpine /overlay /
COPY --from=busybox / /bin
COPY --from=nushell / /
ARG BF_IMAGE
ARG BF_PUBLISHING
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
NU_VERSION=<%= ${NU_VERSION} %>
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 && \
# reset /tmp permissions
chmod 1777 /tmp && \
# add packages required by Nushell
apt update && apt install --no-install-recommends -y libgit2-dev openssl sqlite3 && \
# setup Nushell using preinstallation script
chmod +x /preinstall && /preinstall && \
# run standard bf installation executable
<%= ${BF_BIN} %>/bf-install
#======================================================================================================================
# STAGE 5: 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" ]