Skip to content

Commit

Permalink
docs(docker-build): Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy351 committed May 15, 2020
1 parent d72ebe3 commit 4622ab2
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/docker-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,57 @@ Install the latest plugin.
```sh
yarn plugin import https://github.com/Dcard/yarn-plugins/releases/latest/download/plugin-docker-build.js
```

## Dockerfile

The following is a basic example of `Dockerfile`.

```dockerfile
FROM node:12-alpine AS builder

# Install dependencies for building native libraries
RUN apk add --update git openssh-client python make gcc g++

WORKDIR /workspace

# docker-build plugin copies everything needed for `yarn install` to `manifests` folder.
COPY manifests ./

RUN yarn install --immutable

# You can delete the cache folder after `yarn install` is done.
RUN rm -rf .yarn/cache

FROM node:12-alpine

WORKDIR /workspace

# Copy the installed dependencies from the previous stage.
COPY --from=builder /workspace ./

# docker-build plugin runs `yarn pack` in all workspace dependencies and copies them to `packs` folder.
COPY packs ./

CMD yarn workspace @foo/bar start
```

## CLI

### `yarn docker build`

This command will build a efficient Docker image which only contains production dependencies for the specified workspace.

You have to create a `Dockerfile` in your workspace or your project. You can also specify the path to Dockerfile using the `-f, --file` option.

Additional arguments can be passed to `docker build` directly, please check the Docker docs for more info: https://docs.docker.com/engine/reference/commandline/build/

Example:

```sh
yarn docker build @foo/bar
yarn docker build @foo/bar -t image-tag
```

#### `-f,--file`

Path to `Dockerfile`. Default to the Dockerfile in the workspace or the project.

0 comments on commit 4622ab2

Please sign in to comment.