-
-
Notifications
You must be signed in to change notification settings - Fork 131
Development with docker compose
If you don’t want to install node and/or the other tools needed for working on graphile-build, you can use docker-compose to easily set up a development environment
- Install Docker & docker-compose
- Put those two files at the repository root:
# docker-compose.yml
version: "3"
services:
js: &js
build: .
volumes:
- .:/gb:rw
working_dir: /gb
depends_on: [db]
environment:
TEST_DATABASE_URL: postgres://gb@db:5432/gb
yarn:
<<: *js
entrypoint: ["yarn"]
lerna:
<<: *js
entrypoint: ["lerna"]
npm:
<<: *js
entrypoint: ["npm"]
bash:
<<: *js
entrypoint: ["bash"]
db:
image: postgres:9.6-alpine
environment:
POSTGRES_USER: gb
POSTGRES_PASSWORD: ""
# Dockerfile
FROM node:8
RUN apt-get update && apt-get install -y postgresql-client
RUN npm install -g lerna yarn flow-bin
To simplify the command I recommend adding this alias:
# ~/.bash_aliases
alias run="docker-compose run --rm"
When in the graphile-repository, you have access to all command defined in defined in docker-compose.yml
like this:
run yarn
run lerna bootstrap
run npm run watch
Watch will keep monitoring and compiling the babel files. Then to run the tests in another terminal:
All commands will be executed from the repository root regardless on the folder you’re in in the repository, if you want to change directory you can enter the container environment by running run bash
and you then can change directory and run commands as you would without docker.
run lerna run test
docker-compose automatically configure and start a postgres server for you to run the tests.
To stop and remove any image and container created with docker-compose, just run docker-compose down