Browse Source

migrate from debian to alpine base image (reduces image size from 130MB to 46MB)

Fabian Peter Hammerle 2 years ago
parent
commit
c8caf20fe6
1 changed files with 7 additions and 6 deletions
  1. 7 6
      Dockerfile

+ 7 - 6
Dockerfile

@@ -1,5 +1,4 @@
-# TODO test alpine base image
-FROM docker.io/debian:bullseye-slim
+FROM docker.io/alpine:3.15.0
 
 # > $ grep -azoP -- '\-+BEGIN CERTIFICATE\-+[\sa-zA-Z0-9\+/]+\=*\s\-+END CERTIFICATE\-+\s' \
 # >   /usr/local/bin/toit | openssl x509 -noout -serial -subject -issuer -dates -fingerprint
@@ -9,11 +8,13 @@ FROM docker.io/debian:bullseye-slim
 # > notBefore=Aug 13 00:00:42 2020 GMT
 # > notAfter=Sep 30 00:00:42 2027 GMT
 # > SHA1 Fingerprint=34:9C:38:5F:F8:E3:30:F2:0E:AD:73:3C:D3:6F:B4:35:FE:E0:B4:03
-RUN apt-get update \
-    && apt-get install --no-install-recommends --yes ca-certificates curl \
+
+# https://web.archive.org/web/20220220103519/https://github.com/hadolint/hadolint/wiki/DL4006
+SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
+# hadolint ignore=DL3018
+RUN apk add --no-cache ca-certificates curl \
     && curl https://archive.toit.io/cli/v1.18.2/linux \
         | tar -xvzf - -C /usr/local/bin \
-    && apt-get install --autoremove --yes ca-certificates curl \
-    && rm -r /var/lib/apt/lists/*
+    && apk del ca-certificates curl
 
 # TODO change user