diff --git a/Dockerfile b/Dockerfile index b76ba61dc..f38b1e707 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,29 +9,18 @@ RUN apt-get update -qq && \ default-jre-headless \ unison \ sudo graphviz --no-install-recommends \ - sudo libfile-mimeinfo-perl && \ + libfile-mimeinfo-perl && \ rm -rf /var/lib/apt/lists/* # heroku tools RUN wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh -# install gems -COPY Gemfile* /tmp/ -COPY addons /tmp/addons -WORKDIR /tmp -RUN bundle install -RUN rm -rf addons +ENV BUNDLE_PATH /usr/src/bundle +RUN mkdir $BUNDLE_PATH # create app directory ENV APP_HOME /usr/src/app RUN mkdir $APP_HOME WORKDIR $APP_HOME -RUN mkdir addons -RUN ln -s $(readlink -f addons) /tmp - -# container user -RUN groupadd scinote -RUN useradd -ms /bin/bash -g scinote scinote -USER scinote CMD rails s -b 0.0.0.0 diff --git a/Dockerfile.production b/Dockerfile.production index 63bc9f0da..375cae2e1 100644 --- a/Dockerfile.production +++ b/Dockerfile.production @@ -9,13 +9,15 @@ RUN apt-get update -qq && \ netcat \ default-jre-headless \ sudo graphviz --no-install-recommends \ - sudo libfile-mimeinfo-perl && \ + libfile-mimeinfo-perl && \ rm -rf /var/lib/apt/lists/* # install gems COPY Gemfile* /tmp/ +COPY addons /tmp/addons WORKDIR /tmp RUN bundle install +RUN rm -rf addons # create app directory ENV APP_HOME /usr/src/app diff --git a/Makefile b/Makefile index d145451c7..7f2b4932a 100644 --- a/Makefile +++ b/Makefile @@ -53,7 +53,7 @@ rails-production: run: rm tmp/pids/server.pid || true @docker-compose up -d - @docker attach $(shell docker-compose ps web | grep "rails s" | awk '{ print $$1; }') + @docker attach scinote_web_development start: @docker-compose start diff --git a/docker-compose.yml b/docker-compose.yml index 435dff1d7..ed0560df5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,22 +1,35 @@ +version: '2.1' +services: + db: + container_name: scinote_db_development + image: postgres:9.4 + volumes: + - scinote_development_postgres:/var/lib/postgresql/data -dbdata: - image: busybox - volumes: - - /var/lib/postgresql - command: "true" + web: + build: + context: . + dockerfile: Dockerfile + image: scinote_web_development + container_name: scinote_web_development + stdin_open: true + tty: true + depends_on: + - db + ports: + - "3000:3000" + command: > + bash -c "rm -f /usr/src/app/tmp/pids/server.pid && + (bundle check || bundle install) && + bundle exec rails s -b 0.0.0.0" + environment: + - RAILS_ENV=development + volumes: + - .:/usr/src/app + - scinote_development_bundler:/usr/src/bundle + - scinote_development_files:/usr/src/app/public/system -db: - image: postgres:9.4 - volumes_from: - - dbdata - -web: - build: . - stdin_open: true - tty: true - ports: - - "3000:3000" - volumes: - - .:/usr/src/app - links: - - db +volumes: + scinote_development_postgres: + scinote_development_bundler: + scinote_development_files: