What's the right way to set up a development environment on OS X with Docker?

后端 未结 10 1372
野性不改
野性不改 2020-12-04 05:39

Intro

I can\'t figure out a good way to set up a development environment on OS X using Docker and Boot2Docker. The problem I\'m hitting is how to manage the source

10条回答
  •  甜味超标
    2020-12-04 06:02

    I've been developing in a OS X (mid 2011 Macbook Air) + Boot2Docker + Docker-compose environment for a few weeks now. Haven't run into major performance issues but I avoid running any sort of build when developing (why not use something like jekyll serve --skip-initial-build?). Here's an example docker-compose.yml file I'm using:

    docker-compose.yml:

    test:
      build: .
      volumes:
        - ./client:/src/client
        - ./server:/src/server
        - ./test:/src/test
      command: nodemon --exec jasmine-node -- test/ --verbose --autotest --captureExceptions --color
      environment:
        - DEBUG=*
    

    Dockerfile:

    FROM node:0.12
    
    RUN mkdir -p /src
    WORKDIR /src
    
    ENV PATH=/src/node_modules/.bin:$PATH
    
    # We add package.json first so that we the
    # image build can use the cache as long as the
    # contents of package.json hasn't changed.
    
    COPY package.json /src/
    RUN npm install --unsafe-perm
    
    COPY . /src
    
    CMD [ "npm", "start" ]
    EXPOSE 3000
    

    I sometimes use NFS (http://syskall.com/using-boot2docker-using-nfs-instead-of-vboxsf/) but haven't noticed a big performance difference when doing so.

    For me, the convenience of a simple docker-compose up test to get my environment running has been worth the cost in performance (I routinely work on multiple projects with different stacks).

    PS: nodemon is one of the few file watchers which work with vboxsf (see https://github.com/remy/nodemon/issues/419).

提交回复
热议问题