diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000000..e25a73be14f7 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +# Reference: https://docs.docker.com/engine/reference/builder/#dockerignore-file +# Exclude node_modules +node_modules \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index f1775c014981..839883fbd8a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cc3f55ca834d..b731b544eb8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,6 +32,28 @@ _Before_ submitting a pull request, please make sure the following is doneā€¦ Note: Replace `` 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`. diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000000..c9d990710cce --- /dev/null +++ b/Dockerfile @@ -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"]