Skip to content

Commit

Permalink
fix: much smaller docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad Nassri committed Sep 5, 2022
1 parent 85a6aa0 commit 9f69c1f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
41 changes: 24 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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 <ahmad@ahmadnassri.com>"
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"]
2 changes: 1 addition & 1 deletion action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"release"
],
"engines": {
"node": ">=18"
"node": ">=16"
},
"main": "index.js",
"type": "module",
Expand Down

0 comments on commit 9f69c1f

Please sign in to comment.