From 9f69c1f798aa6a03817201b1d84c6cd714463f64 Mon Sep 17 00:00:00 2001 From: Ahmad Nassri Date: Mon, 5 Sep 2022 19:30:39 +0000 Subject: [PATCH] fix: much smaller docker image --- Dockerfile | 41 ++++++++++++++++++++++++----------------- action/package.json | 2 +- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3db1221..d87942f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,33 +1,40 @@ -FROM node:18-slim +# --- base stage --- # -LABEL com.github.actions.name="Conventional Semantic Release" \ - com.github.actions.description="Semantic Release with all the presets" \ - com.github.actions.icon="package" \ - com.github.actions.color="red" \ - maintainer="Ahmad Nassri " +FROM alpine:3.16 AS base + +# hadolint ignore=DL3018 +RUN apk add --no-cache --update nodejs npm git openssh ca-certificates ruby-bundler + +RUN git config --global --add safe.directory /github/workspace -# set working dir -RUN mkdir /action WORKDIR /action +ENTRYPOINT [ "node" ] + +# --- build stage --- # + +FROM base AS build + # slience npm +# hadolint ignore=DL3059 RUN npm config set update-notifier=false audit=false fund=false -RUN apt-get update \ - && apt-get install -y --no-install-recommends git openssh-client ca-certificates ruby-full \ - && apt-get purge -y --auto-remove \ - && rm -rf /var/lib/apt/lists/* \ - && gem install bundler +# keyscan github.com +RUN mkdir -p ~/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts # install packages COPY action/package* ./ RUN npm ci --omit=dev --no-fund --no-audit -# keyscan github.com -RUN mkdir -p ~/.ssh && ssh-keyscan github.com >> ~/.ssh/known_hosts +# --- app stage --- # + +FROM base AS app + +# copy from build image +COPY --from=build /root/.ssh/known_hosts /root/.ssh/known_hosts +COPY --from=build /action/node_modules ./node_modules # copy files COPY action ./ -# set entry point -ENTRYPOINT ["node", "--no-warnings=ExperimentalWarnings", "/action/index.js"] +CMD ["--no-warnings=ExperimentalWarnings", "/action/index.js"] diff --git a/action/package.json b/action/package.json index 66ed3c9..c86d7af 100644 --- a/action/package.json +++ b/action/package.json @@ -24,7 +24,7 @@ "release" ], "engines": { - "node": ">=18" + "node": ">=16" }, "main": "index.js", "type": "module",