・ Docker: 19.03.8 -Docker-Compose: 1.25.5 ・ Ruby: 2.5.7 Rails: 5.2.4 ・ Vagrant: 2.2.7 -VirtualBox: 6.1 ・ OS: macOS Catalina
The following has been implemented.
-How to build an environment with Docker
When docker-compose is executed, extra files such as temp, log, vendor, and .git are mounted.
Overwrite the mount of the directory that does not need to be mounted with another volume.
docker-compose.ymldocker-compose.yml
#Change before
version: '3'
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
#After change
version: '3'
services:
db:
image: postgres
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
- POSTGRES_HOST_AUTH_METHOD=trust
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
volumes:
- .:/app:cached
- /app/vendor
- /app/tmp
- /app/log
- /app/.git
ports:
- '3000:3000'
depends_on:
- db
Recommended Posts