Skip to content
This repository was archived by the owner on Aug 12, 2020. It is now read-only.

Commit e10b650

Browse files
committed
Add and document Docker support.
1 parent f83b32d commit e10b650

File tree

5 files changed

+90
-52
lines changed

5 files changed

+90
-52
lines changed

Dockerfile

+5-27
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
1-
FROM dockerfile/nodejs
1+
FROM node:4
22

3-
MAINTAINER Matthias Luebken, [email protected]
3+
RUN apt-get update && \
4+
apt-get install -y ruby-full && \
5+
gem install sass
46

5-
WORKDIR /home/mean
6-
7-
# Install Mean.JS Prerequisites
8-
RUN npm install -g grunt-cli
9-
RUN npm install -g bower
10-
11-
# Install Mean.JS packages
12-
ADD package.json /home/mean/package.json
13-
RUN npm install
14-
15-
# Manually trigger bower. Why doesnt this work via npm install?
16-
ADD .bowerrc /home/mean/.bowerrc
17-
ADD bower.json /home/mean/bower.json
18-
RUN bower install --config.interactive=false --allow-root
19-
20-
# Make everything available for start
21-
ADD . /home/mean
22-
23-
# currently only works for development
24-
ENV NODE_ENV development
25-
26-
# Port 3000 for server
27-
# Port 35729 for livereload
28-
EXPOSE 3000 35729
29-
CMD ["grunt"]
7+
ENV PATH /tenants/node_modules/.bin:$PATH

README.md

+55-13
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,22 @@ This is the codebase for the JustFix.nyc platform, including the Tenant Webapp,
44

55
This guide assumes that you are using a [UNIX](http://i.imgur.com/uE6fkx7.gif) system (most likely macOS), but everything is available on Windows if you follow the appropriate guides thru the links below.
66

7+
There are two ways to get started. Both require a bit of common setup.
8+
9+
### Common setup
10+
11+
1. Get a copy of the code!
12+
13+
```
14+
git clone https://github.com/JustFixNYC/tenants.git
15+
```
16+
17+
2. You should have a `development.js` copy from me. (If not, email me at [[email protected]](mailto:[email protected])). Place that file in `config/env`.
18+
19+
Now you have the option to set up and run everything locally, or use Docker.
20+
21+
### Option 1: Run everything locally
22+
723
#### Build tools and languages
824

925
0. Open terminal. Some of these steps may require `sudo` in order to install.
@@ -35,28 +51,20 @@ This guide assumes that you are using a [UNIX](http://i.imgur.com/uE6fkx7.gif) s
3551

3652
#### Download and install libraries
3753

38-
1. Get a copy of the code!
39-
40-
```
41-
git clone https://github.com/JustFixNYC/tenants.git
42-
```
43-
44-
2. You should have a `development.js` copy from me. (If not, email me at [[email protected]](mailto:[email protected])). Place that file in `config/env`.
45-
46-
3. Use npm to install the needed back-end and buildtool libraries. It should trigger a `bower install` for front-end dependencies automatically. Make sure you're in the root directory for the project - i.e. the same level as the `package.json` file.
54+
Use npm to install the needed back-end and buildtool libraries. It should trigger a `bower install` for front-end dependencies automatically. Make sure you're in the root directory for the project - i.e. the same level as the `package.json` file.
4755

4856
```
4957
npm install
5058
```
5159

52-
#### Regular use
60+
#### Start everything up
5361

5462
1. To start, you'll need an active mongodb instance running. I like to do this in a folder within `app` - e.g. `app/mongodb` but it can be run globally or anywhere else.
5563

5664
```
5765
mongod --dbpath . &
5866
```
59-
Open a new terminal window and make sure its running:
67+
Open a new terminal window and make sure it's running:
6068
```
6169
ps aux | grep mongo
6270
```
@@ -73,9 +81,43 @@ You should see the process running, as well as the `grep mongo` command process
7381
grunt
7482
```
7583

76-
3. Go to `http://localhost:3000` to see your development version! Grunt will watch for any changes you make to the code and automatically restart the server for live development.
84+
### Option 2: Use Docker
85+
86+
1. Download [Docker Community Edition](https://www.docker.com/community-edition).
87+
88+
2. Run `bash docker-update.sh`.
89+
90+
Note that in the future, you'll want to run this whenever you update the repository or switch branches, too, to make sure you have all the latest dependencies.
91+
92+
3. Run `docker-compose up`.
93+
94+
### Visit your local server
95+
96+
Now that you've got everything up and running, go to `http://localhost:3000` to see your development version! Grunt will watch for any changes you make to the code and automatically restart the server for live development.
97+
98+
### Tips on using Docker
99+
100+
If you decided to go the Docker route but aren't very familiar with Docker, here are some tips.
101+
102+
#### Running command-line tools
103+
104+
If you ever want to run an individual command-line tool on the project, such as a specific grunt task or linter, you can dive into your Docker's main `web` container by running:
105+
106+
```
107+
docker-compose run web bash
108+
```
109+
110+
You will be in the container's `/tenants` directory, which maps to the root of your repository on your local machine.
111+
112+
Alternatively, you can run individual commands just by running `docker-compose run web <command name>`. Some people do this so often that they create a shell alias called `dcr` that's short for `docker-compose run`.
113+
114+
#### Uninstalling or starting from scratch
115+
116+
If you ever get your Docker setup into a weird state where nothing works, or if you're done with the project and want to free all resources used by Docker, run `docker-compose down -v`.
117+
118+
You'll then need to re-run `bash docker-update.sh` set everything up again.
77119

78-
#### More Questions
120+
### More Questions
79121

80122
Check out [MEAN.JS](http://meanjs.org/docs/0.3.x/) - will have more tutorials on the architecture setup and things for troubleshooting.
81123

docker-compose.yml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: '3'
2+
services:
3+
web:
4+
build: .
5+
volumes:
6+
- .:/tenants:delegated
7+
- node_modules:/tenants/node_modules
8+
working_dir: /tenants
9+
command: grunt
10+
links:
11+
- db
12+
ports:
13+
- "3000:3000"
14+
- "35729:35729" # livereload
15+
environment:
16+
NODE_ENV: development
17+
MONGODB_URI: mongodb://db
18+
db:
19+
image: mongo
20+
ports:
21+
- "27017:27017"
22+
volumes:
23+
node_modules:

docker-update.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#! /bin/bash
2+
3+
set -e
4+
5+
docker-compose build
6+
docker-compose run web npm install
7+
docker-compose run web npm run postinstall -- --allow-root

fig.yml

-12
This file was deleted.

0 commit comments

Comments
 (0)