|
1 | | -FROM registry.suse.com/bci/bci-busybox:15.5 |
| 1 | +FROM registry.suse.com/bci/bci-busybox:15.5 as builder |
2 | 2 |
|
3 | | -COPY bin/cis-operator /usr/bin/ |
| 3 | +# There is no real need for containers to fully comply with the |
| 4 | +# Filesystem Hierarchy Standard (FHS). However, some applications |
| 5 | +# could malfunction if some specific basic dirs are not available. |
| 6 | +# Therefore, create top level structure. |
| 7 | +# |
| 8 | +# https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html |
| 9 | +RUN mkdir -p /final/boot && \ |
| 10 | + mkdir -p /final/etc && \ |
| 11 | + mkdir -p /final/home && \ |
| 12 | + mkdir -p /final/lib && \ |
| 13 | + mkdir -p /final/lib64 && \ |
| 14 | + mkdir -p /final/media && \ |
| 15 | + mkdir -p /final/mnt && \ |
| 16 | + mkdir -p /final/opt && \ |
| 17 | + mkdir -p /final/run && \ |
| 18 | + mkdir -p /final/usr/sbin && \ |
| 19 | + mkdir -p /final/var/lib/nobody |
4 | 20 |
|
5 | | -USER 65535:65535 |
| 21 | +# Some dirs require very specific permissions. |
| 22 | +RUN install -dv -m 0750 /final/root && \ |
| 23 | + install -dv -m 1777 /final/tmp /final/var/tmp |
| 24 | + |
| 25 | +# Keep name search configured in line with BCI. |
| 26 | +RUN cp /etc/nsswitch.conf /final/etc |
| 27 | + |
| 28 | +# Differs from BCI, by removing /bin/sh from root: |
| 29 | +RUN echo "root:x:0:0:root:/root:/usr/bin/false\nnobody:x:65534:65534:nobody:/var/lib/nobody:/usr/bin/false" > /final/etc/passwd |
| 30 | + |
| 31 | +RUN cp /etc/shadow /final/etc |
| 32 | +RUN cp /etc/group /final/etc |
| 33 | + |
| 34 | +COPY bin/cis-operator /final/usr/bin/ |
| 35 | + |
| 36 | +FROM scratch as final |
| 37 | + |
| 38 | +COPY --from=builder /final/ / |
| 39 | + |
| 40 | +# Aligns nobody user ID with BCI. |
| 41 | +USER 65534:65534 |
| 42 | +ENV PATH=/usr/bin |
6 | 43 |
|
7 | 44 | CMD ["cis-operator"] |
0 commit comments