Rails 6 API Development and GitHub Actions CI with Docker (docker-compose.yml)
version: "3.7" | |
services: | |
db: | |
image: mysql:8.0.20 | |
command: --default-authentication-plugin=mysql_native_password | |
environment: | |
- MYSQL_ROOT_PASSWORD | |
- MYSQL_ALLOW_EMPTY_PASSWORD | |
volumes: | |
- mysql-data:/var/lib/mysql | |
ports: | |
- ${MYSQL_FORWARDED_PORT:-3306}:3306 | |
- ${MYSQL_FORWARDED_X_PORT:-33060}:33060 | |
base: &base | |
build: | |
context: . | |
dockerfile: ./Dockerfile | |
cache_from: | |
- rails6api-development-cache | |
args: | |
ARG_RUBY_VERSION: ${ARG_RUBY_VERSION:-2.7.1} | |
image: rails6api-development:0.1.0 | |
tmpfs: | |
- /tmp | |
wait-middleware: &wait-middleware | |
<<: *base | |
environment: | |
WAIT_HOSTS: db:3306 | |
depends_on: | |
- db | |
command: /wait | |
backend: &backend | |
<<: *base | |
stdin_open: true | |
tty: true | |
volumes: | |
- ./:/app:cached | |
- ${GEMS_CACHE_DIR:-bundle-cache}:/bundle | |
- rails-cache:/app/tmp/cache | |
depends_on: | |
- db | |
console: | |
<<: *backend | |
ports: | |
- 3333:3000 | |
command: /bin/bash | |
server: | |
<<: *backend | |
ports: | |
- 3333:3000 | |
command: bash -c "rm -f tmp/pids/server.pid && rails s -b 0.0.0.0" | |
volumes: | |
mysql-data: | |
bundle-cache: | |
rails-cache: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment