Tuesday, January 6, 2015

Develop Meteor Projects with Codenvy

Meteor provides a good framework for developing web based applications. I also like having projects in a cloud based IDE so I can quickly get back to projects whenever I have time regardless of what computer I happen to be near. Codenvy is a nice cloud IDE with some powerful features; but it doesn't exactly come with support for Meteor out of the box. In order to use Meteor with Codenvy we need a custom Docker builder.

Meteor Docker File
FROM codenvy/shellinabox
# 
RUN sudo apt-get update -qq && \
    sudo apt-get -yqq install curl
#
RUN cd /home/user && \
    sudo curl -o /home/user/install_meteor.sh https://install.meteor.com 2> /dev/null && \
    sudo sh install_meteor.sh 2> /dev/null && \
    sudo meteor create app && \
    sudo rm app/app.*
#
ENV CODENVY_APP_PORT_8081_HTTP 8081
EXPOSE 8081
#
# Add meteor packages
RUN cd /home/user/app && sudo meteor add accounts-ui
# 
ADD $app$ /home/user/app/
# 
CMD cd /home/user/app && sudo meteor --port 8081
#


The solution works well but isn't perfect. Your code gets packaged into the Docker container so you can't edit files in your IDE and have the changes hot-deployed into your running application. You will have to stop and restart your application to see changes. Hopefully that is something Codenvy will fix in the future with Docker volumes.
Hot-deployed changes works when you replace
ADD $app$ /home/user/app/
with
VOLUME ["/home/user/app"]
ENV CODENVY_APP_BIND_DIR /home/user/app
but you also have to make sure you have a .meteor directory in your project with the correct configuration files.

2 comments:

  1. You can actually mount sources but not add them. This way you can preview changes in real time:


    VOLUME ["/home/user/app"]
    ENV CODENVY_APP_BIND_DIR /home/user/app

    Use this instead of ADD.

    ReplyDelete