Guest User

Untitled

a guest
Mar 26th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.87 KB | None | 0 0
  1. docker run -it --rm --user "$(id -u):$(id -g)"
  2. -v "$PWD":/usr/src/app -w /usr/src/app rails rails new --skip-bundle --api --database postgresql webapp
  3.  
  4. cd webapp
  5.  
  6. server {
  7. listen 80;
  8. server_name _;
  9. root /home/user/Desktop/me/docker-kubernets;
  10.  
  11. passenger_enabled on;
  12. passenger_user app;
  13.  
  14. passenger_ruby /usr/bin/ruby2.4;
  15. }
  16.  
  17. env SECRET_KEY_BASE;
  18. env DATABASE_URL;
  19. env DATABASE_PASSWORD;
  20.  
  21. FROM phusion/passenger-ruby24
  22. # Set correct environment variables.
  23. ENV HOME /root
  24. # Use baseimage-docker's init process.
  25. CMD ["/sbin/my_init"]
  26. # Additional packages: we are adding the netcat package so we can
  27. # make pings to the database service
  28. RUN apt-get update && apt-get install -y -o Dpkg::Options::="--force-confold" netcat
  29. # Enable Nginx and Passenger
  30. RUN rm -f /etc/service/nginx/down
  31. # Add virtual host entry for the application. Make sure
  32. # the file is in the correct path
  33. RUN rm /etc/nginx/sites-enabled/default
  34. ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf
  35. # In case we need some environmental variables in Nginx. Make sure
  36. # the file is in the correct path
  37. ADD rails-env.conf /etc/nginx/main.d/rails-env.conf
  38. # Install gems: it's better to build an independent layer for the gems
  39. # so they are cached during builds unless Gemfile changes WORKDIR /tmp
  40. ADD Gemfile /tmp/
  41. ADD Gemfile.lock /tmp/
  42. RUN bundle install
  43. # Copy application into the container and use right permissions: passenger
  44. # uses the app user for running the application RUN mkdir /home/app/webapp
  45. COPY . /home/user/Desktop/me/docker-kubernets
  46. RUN usermod -u 1000 app
  47. RUN chown -R app:app /home/user/Desktop/me/docker-kubernets
  48. WORKDIR /home/user/Desktop/me/docker-kubernets
  49. # Clean up APT when done.
  50. RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
  51. EXPOSE 80
  52.  
  53. #!/bin/sh
  54.  
  55. echo "Waiting PostgreSQL to start on 5432..."
  56.  
  57. while ! nc -z postgres 5432; do
  58. sleep 0.1
  59. done
  60.  
  61. echo "PostgreSQL started"
  62.  
  63. bin/rails db:migrate
  64.  
  65. chmod +x setup.sh
  66.  
  67. version: '2'
  68. services:
  69. webapp_setup:
  70. build: .
  71. depends_on:
  72. - postgres
  73. environment:
  74. - PASSENGER_APP_ENV=development
  75. entrypoint: ./setup.sh
  76. webapp:
  77. container_name: webapp
  78. build: .
  79. depends_on:
  80. - postgres
  81. - webapp_setup
  82. environment:
  83. - PASSENGER_APP_ENV=development
  84. ports:
  85. - "80:80"
  86. volumes:
  87. - .:/home/user/Desktop/me/docker-kubernets
  88.  
  89. postgres:
  90. image: postgres:10.2.1
  91. environment:
  92. - POSTGRES_PASSWORD=mysecretpassword
  93. - POSTGRES_USER=webapp
  94. - POSTGRES_DB=webapp_development
  95. volumes_from:
  96. - postgres_data
  97. postgres_data:
  98. image: postgres:10.2.1
  99. volumes:
  100. - /var/lib/postgresql/data
  101. command: /bin/true
  102.  
  103. docker run --rm -v $(pwd):/usr/src/app -w /usr/src/app ruby:2.4.2 bundle lock
  104.  
  105. Could not locate Gemfile
  106. ERROR: Service 'webapp_setup' failed to build: The command '/bin/sh -c bundle install' returned a non-zero code: 10
Add Comment
Please, Sign In to add comment