Skip to content

Commit

Permalink
Merge pull request #401 from marp-team/docker-multi-stage-build
Browse files Browse the repository at this point in the history
Update Dockerfile to split build into multi-stages
  • Loading branch information
yhatt authored Nov 6, 2021
2 parents 31ba07d + f1e00cb commit 96fe625
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ commands:
docker buildx build --no-cache --platform linux/amd64,linux/arm64 --progress plain --push -t marpteam/marp-cli:<< parameters.tag >> .
environment:
DOCKER_CLI_EXPERIMENTAL: enabled
no_output_timeout: 20m

jobs:
audit:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Upgrade Marpit to [v2.1.2](https://github.com/marp-team/marpit/releases/tag/v2.1.2) ([#399](https://github.com/marp-team/marp-cli/pull/399))
- Upgrade Marp Core to [v2.2.0](https://github.com/marp-team/marp-core/releases/tag/v2.2.0) ([#399](https://github.com/marp-team/marp-cli/pull/399))
- Upgrade development Node LTS and dependencies to the latest ([#399](https://github.com/marp-team/marp-cli/pull/399))
- Update `Dockerfile` to make a image with multi-stage builds ([#401](https://github.com/marp-team/marp-cli/pull/401))

## v1.4.1 - 2021-09-26

Expand Down
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
FROM node:16.13.0-alpine
ARG NODE_VERSION=16.13.0

########## Build Marp CLI

FROM node:${NODE_VERSION} AS builder
WORKDIR /usr/src/marp
COPY . .
RUN yarn install --frozen-lockfile && yarn build && rm -rf node_modules src rollup.config.js tsconfig.json

########## Build the image

FROM node:${NODE_VERSION}-alpine
LABEL maintainer "Marp team"

RUN apk update && apk upgrade && \
Expand All @@ -23,18 +34,16 @@ RUN addgroup -S marp && adduser -S -g marp marp \
&& mkdir -p /home/marp/app /home/marp/.cli \
&& chown -R marp:marp /home/marp

# Install node dependencies, and create v8 cache by running Marp CLI once
USER marp
ENV CHROME_PATH /usr/bin/chromium-browser

WORKDIR /home/marp/.cli
COPY --chown=marp:marp . /home/marp/.cli/
RUN yarn add puppeteer-core@chrome-$(chromium-browser --version | sed -r 's/^Chromium ([0-9]+).+$/\1/') || true
RUN yarn install --frozen-lockfile && yarn build && \
rm -rf ./src ./node_modules && yarn install --production --frozen-lockfile && yarn cache clean \
&& node /home/marp/.cli/marp-cli.js --version
COPY --from=builder --chown=marp:marp /usr/src/marp .
RUN yarn install --production --frozen-lockfile && yarn cache clean && node marp-cli.js --version

# Setup workspace for user
USER root

ENV MARP_USER marp:marp

WORKDIR /home/marp/app
Expand Down

0 comments on commit 96fe625

Please sign in to comment.