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

Simplify development environment setup via Docker Compose #1221

Merged
merged 2 commits into from
Aug 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
npm-debug.log
9 changes: 7 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ API_URL=http://localhost:3005/api
FORCE_URL=https://staging.artsy.net
ARTSY_URL=https://stagingapi.artsy.net
SESSION_SECRET=p0s1tr0n
MONGOHQ_URL=mongodb://localhost:27017/positron
ELASTICSEARCH_PORT=9200

# Local development only for the below; refers to the key in docker-compose.yml
ELASTICSEARCH_URL=http://elasticsearch:9200
MONGOHQ_URL=mongodb://mongodb:27017/positron

[email protected]
DEBUG=api,client,app
SALT=$2a$10$PJrPMBadu1NPdmnshBgFbe
Expand Down Expand Up @@ -34,4 +39,4 @@ INSTANT_ARTICLE_ACCESS_TOKEN=REPLACE
FB_PAGE_ID=REPLACE
DEFAULT_PARTNER_ID=REPLACE
SENTRY_PUBLIC_DSN=REPLACE
SENTRY_PRIVATE_DSN=REPLACE
SENTRY_PRIVATE_DSN=REPLACE
1 change: 1 addition & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ARTSY_URL=http://localhost:5000/__gravity
SESSION_SECRET=p0s1tr0n
MONGOHQ_URL=mongodb://localhost:27017/positron-test
ELASTICSEARCH_URL=http://localhost:9200
ELASTICSEARCH_PORT=9200
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be added to .env.example.

SALT=$2a$10$PJrPMBadu1NPdmnshBgFbe
API_MAX=100
API_PAGE_SIZE=10
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ dump.rdb
.env.ignore
node_modules
.vscode
data
6 changes: 6 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM node:7
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY package.json .
COPY . .
RUN yarn install

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To avoid docker cache invalidation, do yarn install before the second COPY command.

18 changes: 18 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: '2'
services:
elasticsearch:
image: elasticsearch:latest

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, lock to a specific version.

ports:
- "${ELASTICSEARCH_PORT}:${ELASTICSEARCH_PORT}"
mongodb:
image: mongo:latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was getting a connection error from mongo client. I might be missing something, but possibly the port for mongodb also needs to be forwarded and exposed like it is for elasticsearch?

ports:
  - 27017:27017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should lock to a specific version. Production is running 3.0.6, so I would set it to

mongo:3.0

server:
build: .
command: make s
ports:
- "${PORT}:${PORT}"
depends_on:
- elasticsearch
- mongodb
volumes:
- .:/usr/src/app