Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Dockerfile for contributing #9109

Closed
wants to merge 10 commits into from
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Reference: https://docs.docker.com/engine/reference/builder/#dockerignore-file
# Exclude node_modules
node_modules
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
- `[jest-validate]` [**BREAKING**] Use ESM exports ([#8874](https://github.com/facebook/jest/pull/8874))
- `[jest-types]` Mark `InitialOptions` as `Partial` ([#8848](https://github.com/facebook/jest/pull/8848))
- `[jest-config]` Refactor `normalize` to be more type safe ([#8848](https://github.com/facebook/jest/pull/8848))
- `[*]` Added Dockerfile for Jest Development ([#9109](https://github.com/facebook/jest/pull/9109))

### Performance

Expand Down
22 changes: 22 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ _Before_ submitting a pull request, please make sure the following is done…

Note: Replace `<your_username>` with your GitHub username

1. Run Jest with [Docker](https://docs.docker.com/engine/docker-overview/) (Optional) or continue reading for manual instructions.

1. If you haven't already, [Install Docker](https://docs.docker.com/install/).

1. Navigate to the `/jest` directory. You should be able to see the `Dockerfile` file when you run `ls`.

1. Build the Jest image (may take a few minutes):

```sh
docker build -t jest .
```

1. Run the Jest image:

```sh
docker run --volume="YOUR_PATH_TO_JEST:/usr/src/app" --rm jest:latest
```

1. The `yarn run watch` command will watch the `/packages` directory for file changes. See `package.json` for a full list of commands. [Learn how to run commands in a container](https://docs.docker.com/engine/reference/commandline/exec/) or visit the [official Docker docs](https://docs.docker.com/) for other Docker related questions.

1. **Skip to step #8 and continue reading.**

1. Jest uses [Yarn](https://code.facebook.com/posts/1840075619545360) for running development scripts. If you haven't already done so, please [install yarn](https://yarnpkg.com/en/docs/install).

1. Make sure you have `python` installed (v2.7 is recommended, v3.x.x is not supported). Python is required by [node-gyp](https://github.com/nodejs/node-gyp) that is used when running `yarn install`.
Expand Down
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#Build: docker build -t jest .
#Run: docker run --volume="$PWD:/usr/src/app" --rm jest:latest

#Use Node 12.13.0 image
#Includes Python2.7
FROM node:12

#Setup basic environment
ENV DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LC_ALL=C.UTF-8 \
LANGUAGE=en_US.UTF-8

WORKDIR /usr/src/app

#Copy entire directory
COPY . ./

#Install dependencies
RUN yarn

#Build && Watch for changes
ENTRYPOINT ["yarn"]
CMD ["watch"]