Last active
July 9, 2017 17:09
-
-
Save ylecuyer/cc648ed77c82be29b4bba5aa3dd5ff40 to your computer and use it in GitHub Desktop.
Rails Dockerfile
This file contains 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 characters
Para inicializar: | |
docker-compose up | |
esperar a que se cree la base de datos (ie que este quieto el output de db) | |
ctrl+c | |
docker-compose run app bundle install | |
docker-compose run app bundle exec rails db:setup | |
docker-compose up | |
Luego para cualquier comando de rails | |
docker-compose run app bundle exec rails ARGS |
This file contains 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 characters
version: '2' | |
services: | |
db: | |
image: postgres # ultimo postgres | |
ports: | |
- 5432:5432 # Para tener acceso con pgadmin desde la maquina local (host: localhost / username: postgres / password: empty) | |
app: | |
build: | |
context: . | |
dockerfile: Dockerfile # usar el dockerfile definido arriba | |
volumes: | |
- .:/usr/src/app # compartir los archivos de desarrollo | |
ports: | |
- 3000:3000 # tener acceso a la app desde http://localhost:3000 | |
depends_on: # Prender cuando esten listos la base de datos, la gemas, y spring | |
- db | |
- gems | |
- spring | |
volumes_from: | |
- gems # usa las gemas | |
spring: | |
build: | |
context: . | |
dockerfile: Dockerfile | |
command: bundle exec spring server # prender el servidor de spring | |
volumes: | |
- .:/usr/src/app | |
depends_on: | |
- gems | |
volumes_from: | |
- gems # tambien necesita las gemas | |
gems: | |
image: busybox # imagen la mas chiquita que tiene docker, no sirve para nada sino para tener el volumen compartido | |
command: tail -f /dev/null | |
volumes: | |
- /ruby_gems # donde se almacenaran las gemas |
This file contains 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 characters
FROM ruby:2.4.0 | |
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs && apt-get clean | |
WORKDIR /usr/src/app | |
ENV BUNDLE_PATH /ruby_gems | |
ENV GEM_PATH /ruby_gems | |
ENV GEM_HOME /ruby_gems | |
ENV SPRING_TMP_PATH tmp | |
ENV SPRING_SOCKET tmp/spring.sock | |
ENV SPRING_PIDFILE tmp/spring.pid | |
EXPOSE 3000 | |
CMD ["bundle", "exec", "rails", "server", "-b", "0.0.0.0"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment