Skip to content

Commit

Permalink
Merge pull request #14 from marp-team/docker
Browse files Browse the repository at this point in the history
Add official Docker image
  • Loading branch information
yhatt authored Sep 10, 2018
2 parents 5003a65 + 085c32a commit c806b51
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,34 @@ jobs:
docker:
- image: circleci/node:6.14.2-browsers

docker-image:
docker:
- image: docker:git
working_directory: ~/marp-cli
steps:
- checkout
- setup_remote_docker

- run:
name: Build Docker image
command: docker build --no-cache -t marpteam/marp-cli:latest .

- run:
name: Push to Docker Hub
command: |
docker login -u $DOCKER_USER -p $DOCKER_PASS
docker push marpteam/marp-cli:latest
workflows:
version: 2
build:
jobs:
- 8.11.4
- 6.14.2
- docker-image:
requires:
- 8.11.4
- 6.14.2
filters:
branches:
only: master
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**/*
!src/
!LICENSE
!marp-cli.js
!package.json
!rollup.config.js
!tsconfig.json
!yarn.lock
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## [Unreleased]

### Added

- Add official Docker image ([#14](https://github.com/marp-team/marp-cli/pull/14))

## v0.0.7 - 2018-09-06

### Changed
Expand Down
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
FROM node:8.11.4-alpine
LABEL maintainer "Marp team"

RUN apk update && apk upgrade && \
echo @edge http://nl.alpinelinux.org/alpine/edge/community >> /etc/apk/repositories && \
echo @edge http://nl.alpinelinux.org/alpine/edge/main >> /etc/apk/repositories && \
apk add --no-cache \
grep \
chromium@edge \
freetype@edge \
harfbuzz@edge \
nss@edge

RUN addgroup -S marp && adduser -S -g marp marp \
&& mkdir -p /home/marp/app /home/marp/.cli \
&& chown -R marp:marp /home/marp

USER marp
ENV IS_DOCKER true

WORKDIR /home/marp/.cli
COPY --chown=marp:marp . /home/marp/.cli/
RUN yarn install && yarn build \
&& rm -rf ./src ./node_modules && yarn install --production && yarn cache clean

WORKDIR /home/marp/app
ENTRYPOINT ["node", "/home/marp/.cli/marp-cli.js"]
CMD ["--help"]
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ It can convert Marp / Marpit Markdown files into static HTML (and CSS).

## Try it now!

### npx

[npx](https://blog.npmjs.org/post/162869356040/introducing-npx-an-npm-package-runner) is the best tool when you want to convert Markdown right now. Just run below if you are installed [Node.js](https://nodejs.org/) >= 8.2.0:

```bash
Expand All @@ -27,6 +29,18 @@ npx @marp-team/marp-cli slide-deck.md -o output.pdf

> :information_source: You have to install [Google Chrome](https://www.google.com/chrome/) (or [Chromium](https://www.chromium.org/)) to convert slide deck into PDF.
### Docker

Do you hate to install node/chrome locally? We have [an official Docker image](https://hub.docker.com/r/marpteam/marp-cli/) ready to use CLI.

```bash
# Convert slide deck into HTML
docker run --rm -v $PWD:/home/marp/app/ marpteam/marp-cli slide-deck.md

# Convert slide deck into PDF by using Chromium in Docker
docker run --rm -v $PWD:/home/marp/app/ marpteam/marp-cli slide-deck.md --pdf
```

## Install

### Global install
Expand Down
5 changes: 5 additions & 0 deletions src/converter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,16 @@ export class Converter {
}

private static runBrowser() {
const args: string[] = []
const finder: () => string[] = require('is-wsl')
? chromeFinder.wsl
: chromeFinder[process.platform]

if (process.env.IS_DOCKER)
args.push('--no-sandbox', '--disable-dev-shm-usage')

return puppeteer.launch({
args,
executablePath: finder ? finder()[0] : undefined,
})
}
Expand Down

0 comments on commit c806b51

Please sign in to comment.