The onboarding experience should be almost as simple as telling your new developer to just clone the repo and run docker-compose up
. Personally I wouldn't bother worrying about IDE integration because people might prefer to use different IDEs.
Every project/application (if you have multiple) should be able to run separately and each project/application should have it's own codebase. That's a concept from The Twelve-Factor App methodology.
In the root of each project add a Dockerfile
and a docker-compose.yml
file.
NOTE: I created Craft Kits which you can use to automatically generate these files for the framework/language you're using with one command (e.g. mason craft nodejs
), you don't even need to know Docker.
The Dockerfile
will build your application into an image, installing and dependencies your application needs to run. This image is the image that runs your app.
FROM node:8.8-alpine
# Set our workdir
WORKDIR /app
# Install and cache app dependencies
COPY package.json /app
RUN npm install
# Add project files
COPY . /app
# start app
CMD [ "npm", "start" ]
The docker-compose.yml
file will spin up your environment. It will define all the services Docker should start for your application
version: '2'
services:
web:
build: .
volumes:
- ./:/app
ports:
- "3000:3000"
mongodb:
image: mongodb
volumes:
- ./storage/data/mongodb:/data/db
ports:
- "27017:27017"
When you onboard a new developer, you can just tell them to git clone
your repo and to fire up their development environment by running:
docker-compose up -d
The advantage of this approach when you are developing locally, running docker-compose up
will mount your code as a volume.
Then when you want to deploy, when you build your Dockerfile
it will copy your code into your image so everything is packaged up nicely and easily moved around.
We use the same approach for apps on Codemason, my service for building, managing and scaling container-based applications. When you push new code, we automatically build an image from your Dockerfile. Since that image contains everything your app needs to run, it can be easily launched on any server and scaled up/down across multiple servers.