Last active
March 31, 2019 15:42
-
-
Save mokxter/bc88cf5a1f4993614cb6e1ac38e207b5 to your computer and use it in GitHub Desktop.
Revisions
-
mokxter revised this gist
Mar 31, 2019 . 1 changed file with 0 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -78,18 +78,6 @@ services: - '.:/app' - 'tmp:/app/tmp' - 'node_modules:/app/node_modules' ``` ## Build the image / container -
mokxter revised this gist
Mar 31, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -59,7 +59,7 @@ RUN bundle install COPY package.json yarn.lock /app/ ``` ## Create docker-compose.yml ``` version: '3' -
mokxter revised this gist
Mar 31, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ gem install rails ## Create project using rails gem ``` cd workspace rails new app_name --webpack # Exit the container after command have finished. exit ``` -
mokxter revised this gist
Mar 31, 2019 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -90,4 +90,11 @@ services: - '.:/app' - 'tmp:/app/tmp' - 'node_modules:/app/node_modules' ``` ## Build the image / container ``` docker-compose build # or docker-compose up ``` -
mokxter created this gist
Mar 31, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ # Creating a Rails project with Docker. ## Pull ruby gem ``` docker pull ruby:latest ``` ## Run bash using ruby image. ``` docker run -it -v "$(pwd):/workspace" ruby bash ``` ## Install rails ``` gem install rails ``` ## Create project using rails gem ``` cd workspace rails new app_name --webpack --skip-bundle # Exit the container after command have finished. exit ``` ## Create Dockerfile ``` cd app_anme touch Dockerfile vim Dockerfile ``` ### Dockerfile sample / template ``` FROM ruby:2.6.0 ENV BUNDLE_JOBS=4 \ BUNDLE_RETRY=3 RUN apt-get update -qq && \ apt-get install -y build-essential git RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - && \ apt-get install -y nodejs RUN npx n 10.15.0 RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \ apt-get update && apt-get install -y yarn RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* WORKDIR /app COPY Gemfile Gemfile.lock /app/ RUN bundle install COPY package.json yarn.lock /app/ ``` ### Create docker-compose.yml ``` version: '3' volumes: tmp: node_modules: services: web: build: . command: bash -c "rm -rf /app/tmp/pids/service.pid && ./bin/rails s -p 3000 -b '0.0.0.0'" ports: - '3000:3000' volumes: - '.:/app' - 'tmp:/app/tmp' - 'node_modules:/app/node_modules' webpack: build: . command: bash -c "./bin/webpack-dev-server" depends_on: - web ports: - '3035:3035' volumes: - '.:/app' - 'tmp:/app/tmp' - 'node_modules:/app/node_modules' ```