From 23fbd1ae53fc41fe97adf104921ac56a608fc5d8 Mon Sep 17 00:00:00 2001 From: Randolph Sapp Date: Sat, 9 Nov 2024 21:43:13 -0600 Subject: [PATCH] feat(docker): use alpine for the base image Use alpine for our base image since this reduces the container size by about half. Plus, most of this is just Python, bash, and make scripting anyway. Nothing Ubuntu specific anymore. Signed-off-by: Randolph Sapp --- docker/Dockerfile | 25 +++++++------------------ docker/root/init | 2 +- 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 59f2a41ad..e5bf1a221 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,34 +1,23 @@ # SPDX-License-Identifier: MIT # Copyright (C) 2024 Texas Instruments Incorporated - https://www.ti.com -FROM debian:stable-slim +FROM alpine:3 -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - --no-install-recommends \ +RUN apk add --no-cache \ + bash \ dumb-init \ git \ - gosu \ make \ - python3-pip \ + py3-pip \ ripgrep \ + shadow \ + su-exec \ zip \ && echo "**** create abc user and make our folders ****" \ && useradd -u 1000 -U -d /config -s /bin/false abc \ && usermod -G users abc \ && mkdir /build && chown abc:abc /build \ - && mkdir /config && chown abc:abc /config \ - && echo "**** cleanup ****" \ - && apt-get autoremove \ - && apt-get clean \ - && rm -rf \ - /tmp/* \ - /var/cache/debconf/*-old \ - /var/lib/apt/lists/* \ - /var/lib/dpkg/status-old \ - /var/lib/sgml-base/supercatalog.old \ - /var/log/apt/term.log \ - /var/tmp/* + && mkdir /config && chown abc:abc /config RUN --mount=type=bind,source=requirements.txt,target=/tmp/requirements.txt \ python3 -m pip install -r /tmp/requirements.txt --no-cache-dir \ diff --git a/docker/root/init b/docker/root/init index 05ec1431c..5b7737b28 100755 --- a/docker/root/init +++ b/docker/root/init @@ -42,5 +42,5 @@ fi if [ "$(id -u)" == "$(id -u abc)" ]; then exec dumb-init -- "$@" else - exec dumb-init -- gosu abc "$@" + exec dumb-init -- su-exec abc:abc "$@" fi